Hello all,

I want to use a list of computers that I have serial numbers and
corresponding asset numbers for to rename the computers. I have the
compname.exe that works great but want to go a step further.

Is there a way to have vbscript detect the serial number of a computer
then use a list that associates a different name to the serial number
and have the script rename based on that?

Step 1:
Identify & Capture serial number
Step 2:
Compare serial number to list ie
serial number asset number
123456 abcdefg
Step 3:
Rename the computer so that if serial number = 123456 then
computername = abcdefg.

Thanks in advance for any help.

Re: Computer name by Torgeir

Torgeir
Mon Aug 25 16:39:30 CDT 2003

Miphnik wrote:

> I want to use a list of computers that I have serial numbers and
> corresponding asset numbers for to rename the computers. I have the
> compname.exe that works great but want to go a step further.
>
> Is there a way to have vbscript detect the serial number of a computer
> then use a list that associates a different name to the serial number
> and have the script rename based on that?

Yes.


> Step 1:
> Identify & Capture serial number

strComputer = "." ' use "." for local computer

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

Set colBIOS = objWMIService.ExecQuery _
("Select SerialNumber from Win32_BIOS")

For Each objBIOS in colBIOS
strSerialNumber = objBIOS.SerialNumber
Next


If strSerialNumber <> "" Then
WScript.Echo "SN# = " & strSerialNumber
Else
WScript.Echo "Serial number empty"
End If


> Step 2:
> Compare serial number to list ie
> serial number asset number
> 123456 abcdefg

I would have created a dictionary object of the list (object that stores data
key, item pairs) to do this.

WSH 5.6 documentation (local help file) can be downloaded from here if you
haven't got it already:
http://msdn.microsoft.com/downloads/list/webdev.asp

Some examples:
http://groups.google.com/groups?as_epq=Scripting%20Dictionary&safe=images&ie=UTF-8&oe=UTF-8&as_uauthors=Michael%20Harris&lr=&hl=en



> Step 3:
> Rename the computer so that if serial number = 123456 then
> computername = abcdefg.

Changing computer name for WNT/W2k/WXP with vbscript and regwrites:

http://groups.google.com/groups?selm=3DBD6E02.F0D75A0%40hydro.com


If WinXP or newer:

Rename Method in Class Win32_ComputerSystem
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/rename_method_in_class_win32_computersystem.asp

An example:
http://groups.google.com/groups?selm=3E4F0E3A.8476E52E%40hydro.com



--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter



Re: Computer name by daveH

daveH
Mon Aug 25 22:47:20 CDT 2003


Compname.exe :

http://www.willowhayes.co.uk/