Thank you Mr. Harris!
"Michael Harris (MVP)" <mikhar.at.mvps.dot.org> wrote in message news:%23O4Z%23JDuHHA.3796[ at ]TK2MSFTNGP02.phx.gbl...
[Quoted Text] > Les wrote: >> The following code gets me the serial # of a PC but instead of just >> echoing the serial number I'd like to be able to set it to a >> variable, ie Set PCSerial = objItem.SerialNumber >> But if I put that line in after the WScript.Echo I get the following >> error: >> >> C:\Temp\PCSerial.vbs(57, 3) Microsoft VBScript runtime error: Object >> required: '[string: "123FF123"]' >> >> How can I capture this info for use as a variable? >> >> Thank you, >> Les Bowman >> >> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- >> >> '* Query WMI to get the serial number of the PC. >> Set objWMIService = GetObject("winmgmts:\\" & strComputer & >> "\root\CIMV2") '*If the file didn't exist we connect to WMI and get >> the info. Set colItems = objWMIService.ExecQuery("SELECT * FROM >> Win32_BIOS", "WQL", _ wbemFlagReturnImmediately + >> wbemFlagForwardOnly) For Each objItem In colItems >> WScript.Echo "Serial Number/PC Name is = " & objItem.SerialNumber > > 'no Set, SerialNumber is not an object... > PCSerial = objItem.SerialNumber > >> Next > > -- > Michael Harris > Microsoft.MVP.Scripting > >
|