Re: Help will empty field entry handling
- From: Daz <darren.blackley@xxxxxxxxx>
- Date: Sun, 18 May 2008 21:49:59 -0700 (PDT)
On May 19, 11:28 am, "Todd Vargo" <tlva...@xxxxxxxxxxxxxx> wrote:
Daz wrote:
Hi all,
am using the following code to pull the motherboard serial number from
machines, however some 3rd party oem machines have an empty serial
number field and i would like to have the code report "no serial
number found" if the field is empty of null...
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root
\CIMV2")
Set colItems = objWMIService.ExecQuery( "SELECT * FROM
Win32_BaseBoard",,48)
For Each objItem in colItems
If IsNull(objItem.SerialNumber) Then
MsgBox(objItem.SerialNumber)
End If
Next
and
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root
\CIMV2")
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_BaseBoard",,48)
For Each objItem in colItems
Wscript.Echo "-----------------------------------"
Wscript.Echo "Win32_BaseBoard instance"
Wscript.Echo "-----------------------------------"
Wscript.Echo "SerialNumber: " & objItem.SerialNumber
Next
One way is to store the value in a variable.
sn = objItem.SerialNumber
If Trim(sn) = "" Then
sn = "no serial number found"
End If
Another way is to use an IF condition where needed.
For Each objItem in colItems
Wscript.Echo "-----------------------------------"
Wscript.Echo "Win32_BaseBoard instance"
Wscript.Echo "-----------------------------------"
If Trim(objItem.SerialNumber) = "" Then
Wscript.Echo "SerialNumber: no serial number found"
Else
Wscript.Echo "SerialNumber: " & objItem.SerialNumber
End If
Next
--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)
Todd,
Thank you very much for your help - thats perfect! does exactly what i
wanted.
Cheers,
Daz
.
- References:
- Help will empty field entry handling
- From: Daz
- Re: Help will empty field entry handling
- From: Todd Vargo
- Help will empty field entry handling
- Prev by Date: Re: "Select * from Win32_Product" Not Finding All Apps
- Next by Date: how to Open notepad with a command-line argument
- Previous by thread: Re: Help will empty field entry handling
- Next by thread: how to Open notepad with a command-line argument
- Index(es):
Relevant Pages
|