Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need to create a VBS

Status
Not open for further replies.

hammers1118

Programmer
Sep 28, 2012
1
US
I am new to VBScript and need to create one for work purposes. I need to create a script for finding out this information:
Serial Number
MAC Address
Computer Name

pretty basic but i am having a hard time with :( need it for a list of computers :(
 
Query the WMI to get these properties. Use the File System Object to read the list of computers. Here is a basic example (assuming your list of computers is one name or IP per line).

Code:
set objFSO = CreateObject("Scripting.FileSystemObject")
set objInFile = objFSO.OpenTextFile("myList.txt", 1, true, 0)
set objOutFile = objFSO.OpenTextFile("output.txt", 2, true, 0)

do while not objInFile.AtEndOfStream
   strComputer = objInFile.ReadLine
   set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
   set colBIOS = objWMI.ExecQuery("Select * from Win32_BIOS", , 48)
   for each objItem in colBIOS
       strSerialNumber = objItem.SerialNumber
   next
   objOutFile.WriteLine strComputer & "'s serial number is " & strSerialNumber
loop

objOutFile.close
objInFile.close

Simply do a google search to find the other objects and examples to help you. Something like "get MAC remote computer vbscript"

-Geates

"I do not offer answers, only considerations."
- Geates's Disclaimer

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top