Petri.com forums Home Forums Start Page Forums Frequently Asked Questions FAQ Member List Members List
Go Back   Petri IT Knowledgebase Forums > Windows Scripting > General Scripting
Petri.com is happy to award RicklesP the title of Most Valuable Member !!!
Register Calendar Calendar Search Petri IT Knowledgebase Forums Search Todays Posts Today's Posts Mark Forums Read
Notices

Script to get Serial Number from a list of computer.

Script to get Serial Number from a list of computer.

this thread has 2 replies and has been viewed 8279 times

Closed Thread
 
Thread Tools Search this Thread Display Modes
  #1  
Old 28th September 2009, 18:56
Alexito Alexito is offline
Casual
Casual
 
 Join Date: Apr 2009
  6 month star 12 month star
 Posts: 11
 Reputation: Alexito is on a distinguished road (10)
Default Script to get Serial Number from a list of computer.

Hello to all,
I am in the need to write a script to obtain the serial number and model from a list of computer, I have the script below which work fine when it's only one computer but I don't know how to make it work to pick up a list of computer from a text file. Any ideas are welcome,
Thanks in advance,

Code:
On Error Resume Next 

Dim strComputer
strComputer = InputBox("Enter the name of the computer:") 

Set objWMIService = GetObject("winmgmts:" _
   & "{impersonationLevel=impersonate}!\\"  _
   & strComputer & "\root\cimv2") 

Set colSMBIOS = objWMIService.ExecQuery _
   ("Select * from Win32_SystemEnclosure") 
For Each objSMBIOS in colSMBIOS
   MsgBox strComputer & ": " & objSMBIOS.SerialNumber
Next

Set colItems = objWMIService.ExecQuery _
   ("Select * from Win32_ComputerSystem")
For Each objItem in colItems
   Wscript.Echo "System Name: " & objItem.Name
   Wscript.Echo "Manufacturer: " & objItem.Manufacturer
   Wscript.Echo "Model: " & objItem.Model
Next

Call retrieve_Space

Public sub retrieve_Space
   Const HARD_DISK = 3

   Set objWMIService = GetObject("winmgmts:" _
     & "{impersonationLevel=impersonate}!\\" _
     & strComputer & "\root\cimv2")

   Set colDisks = objWMIService.ExecQuery _
     ("Select * from Win32_LogicalDisk Where DriveType = " _
     & HARD_DISK & "")
   For Each objDisk in colDisks
     msgbox "DeviceID: " & objDisk.DeviceID
     msgbox "Free Disk Space: " &  objDisk.FreeSpace
   Next
End Sub

Last edited by Rems; 28th September 2009 at 23:56.. Reason: replaced quote-tags with code-tags
  #2  
Old 28th September 2009, 23:49
Rems's Avatar
Rems Rems is offline
Moderator
 
 Join Date: Mar 2005
  6 month star 12 month star
 Location: NL
 Posts: 2,433
 Reputation: Rems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to behold (965)
Default Re: Script to get Serial Number from a list of computer.

Code:
Const ForReading = 1
strReadFile = "C:\computers.txt"

' start reading computer names from the text file
With CreateObject("Scripting.FileSystemObject")
   Set objTextFile = .OpenTextFile _
      (strReadFile, ForReading)
   intSize = 0
   Do Until objTextFile.AtEndOfStream
      strComputer = trim(objTextFile.ReadLine)
      If strComputer <> Empty then
        ReDim Preserve arrComputers(intSize)
        arrComputers(intSize) = strComputer
        intSize = intSize + 1
      End If
   Loop
   objTextFile.Close: Set objTextFile = Nothing
End With
If not IsArray(arrComputers) _
   Then wscript.echo "No Computers!": wscript.quit(0)

Dim strComputer
For Each strComputer in arrComputers

   ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
   ' your script comes here, but without!!! the folowing 2 lines,
   '     Dim strComputer
   '     strComputer = InputBox("Enter the name of the computer:")
   '
   ' btw... You create the objWMIService 2x in your 
   ' script, while the first only would be sufficient.
   ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Next
wscript.quit 0
Similar Thread
http://forums.petri.com/showthread.php?t=35894

\Rems
__________________

This posting is provided "AS IS" with no warranties, and confers no rights.

__________________

** Remember to give credit where credit's due **
and leave Reputation Points for meaningful posts
  #3  
Old 29th September 2009, 23:31
Alexito Alexito is offline
Casual
Casual
 
 Join Date: Apr 2009
  6 month star 12 month star
 Posts: 11
 Reputation: Alexito is on a distinguished road (10)
Default Re: Script to get Serial Number from a list of computer.

Rems
Thanks for taking your time to reply to my post and suggesting that similar threat, which by the way has some scripts that are more sophisticated, I liked the option of dumping the results into a spreadsheet. I am closing this post since is a repeated issue.
Thanks again for your help,
Alex
Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Channelised ISDN E1/PRI and serial interfaces number metha Cisco Routers & Switches How-to 2 12th September 2007 20:16
VMWare Server needs serial number ?? sorinso VMware Virtualization 7 11th April 2007 07:28
Changing Windows 2000 Pro Serial Number grin Windows 2000 Pro, XP Pro 3 21st December 2005 13:31
hard drive eprom serial number vinny Misc 1 10th December 2005 22:10
Can't change Win XP Pro serial number. algae Windows 2000 Pro, XP Pro 3 13th September 2005 02:35


All times are GMT +3. The time now is 03:36.

Steel Blue 3.5.4 vBulletin Style ©2006 vBEnhanced
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
 

Valid XHTML 1.0!   Valid CSS!

Copyright 2005 Daniel Petri