Video Screencast Help

Automatically Rename PC Upon Reboot?

Created: 14 Jan 2008 • Updated: 21 May 2010 | 6 comments
I cannot use Sysprep on my images, it removes registry & licensing info regarding certain applications. I am using cdboot to a mapped drive in a non-domain environment to image my lab pc's. Multicast/Ghostcast not supported yet on the network either. Is there a batch or script file I can run on first reboot that will rename the PC's?  Ideally since most PC's have integrated nics, I'm thinking along the lines of something like; if MAC address = xx-xx-xx-xx then rename PC to xxxxx. All names are the same character length. Any ideas?



Message Edited by Harry Walsh on 01-14-2008 09:47 PM

Discussion Filed Under:

Comments 6 CommentsJump to latest comment

Krish Jayaratne's picture

Hi Harry,

Ghost Walker can change the computer name with some limitations. The new name should be the same length as the old name. There are different ways generate the names automatically too, based on a pre-fix and random characters. This could be done while in DOS, just after imaging the computer.

If you run Ghost walker manually (ghstwalk.exe) you can try out and see if it is working with the application. After than you can include it in the batch file.

Ghost walker can perform SID changes too.

Krish

Ghostly Dave's picture
Some VBscript code fragments which may be of use to you.
 
To find out MAC addresses of installed NIC's:
 
Code:
On Error Resume Next
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter", "WQL", _
                         wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objNetworkAdapter In colItems
      WScript.Echo objNetworkAdapter.Name & " : " & objNetworkAdapter.MACAddress
Next

To find out system Serial numbers / Asset Tags:

Code:
On Error Resume NextConst wbemFlagReturnImmediately = &h10Const wbemFlagForwardOnly = &h20strComputer = "."Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_BIOS", "WQL", _                        wbemFlagReturnImmediately + wbemFlagForwardOnly)For Each objBIOS In colItems    WScript.Echo "SerialNumber : " & objBIOS.SerialNumberNext


 To rename the computer:

Code:
On Error Resume NextConst wbemFlagReturnImmediately = &h10Const wbemFlagForwardOnly = &h20strComputer = "."strNewComputername = "computer1"Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", _                        wbemFlagReturnImmediately + wbemFlagForwardOnly)For Each objComputerSystem in colItems    objComputerSystem.Rename(strNewComputername)Next


 After renaming you will need to force a reboot, which you can do in VBScript:

 
Code:
Code:
On Error Resume NextConst wbemFlagReturnImmediately = &h10Const wbemFlagForwardOnly = &h20strComputer = "."Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", _                        wbemFlagReturnImmediately + wbemFlagForwardOnly)For Each objOperatingSystem in colItems    objOperatingSystem.reboot()Next


 


 
Use a select/case type statement to compare MAC address / Serial number with a known list and you are done.  

Dave
ghuser01's picture
Hi,
 
I use a freeware tool called Wsname - http://mystuff.clarke.co.nz/MyStuff/wsname.asp - to automatically rename computers. I use this tool along with Sysprep and Ghost.
 
This tool allows me to change computer names to any names I desire. I have a list of pre-defined names that I want to name all the computers, so I first create a text file that contains all the pre-defined computer names.
 
The list should be in this order:
 
MAC=Computer Name
 
(where MAC is computer MAC address and Computer Name is pre-defined computer name)
 
For example,
000123456789=PC23-1234
 
When Wsname runs, it searches the text file, compares the MAC address of the computer on which is running with the MAC address defined in the text file. If both are matching up, Wsname assigns the pre-defined name to the computer.
 
Execute Wsname during computer startup:
 
In Sysprep.inf, I set the computer to automatically logon once after sysprep completes preparing the system. After the logon process completes, a batch script executes Wsname.
 
Sysprep.inf
 
[GuiUnattended]
AdminPassword=*
AutoLogon=Yes 
AutoLogonCount=1
 
[Identification]
Workgroup=Workgroup
 
I define the batch script in the registry so that Wsname runs only one time as I need to change the computer name.
 
Wsname tool also allows changing computer names using MAC address or AssetTag.
 
Thanks.



Message Edited by ghuser01 on 01-25-2008 10:00 AM

Don Weekley's picture

What I am looking for here now is to automate the renaming process of the PC when ghostwalker is run after ghost. 

 

An easy setup would to create a file on the USB drive that I run gdisk/ghost/ghstwalk on to read something like:

 

MAC ADDRESS1 = PC NAME1

MAC ADDRESS2 = PC NAME2

etc.

 

Then I could create and copy as many of these bootable USB drives as I need (approx 30 right now) that would all be identical but able to rename the laptop they are in to the name it always has had after it was re-imaged.

 

What I cannot figure out is how to get the MAC address information into a system variable/batch file when the system boots into pc-dos that came with Ghost so that ghstwalk owuld get the correc tinfo for each machine. I do not want to have to touch these machines once the gdisk/ghost/ghstwalk process has started.

 

How can I get the MAC address from pc-dos? (Remember there is NO windows etc to work with here, the machine has booted into pc-dos from the USB flash drive.)

 

Thanks,

 

Don

 

Krish Jayaratne's picture

Hi, 

 

It took a while to do it, but if you are still interested, please have a look at Juice. Juice now has many articles about Ghost.

 

Direct link to this article is here

 

Krish