Jump to content

Rename a PC from a batch file - Any ideas?


Recommended Posts

Posted

Hi,

 

I want to write a couple of batch files that will be run automatically after a PC has been imaged using ghost. I want the batch files to rename the PC, restart it and then join it to a domain.

 

Getting the PC to auto login and run a batch file is easy enough, but how do I rename it or add it to the domain?

 

I know the netdom utility from one of the MS Resource Kits can do the domain join, but it seems as though the rename only works on PCs already joined to a domain. I need a way of doing it for PC's that aren’t yet on a domain.

 

Thanks

Posted

Yeh you need to sysprep before taking an image otherwise you'lll have lots of issues including SID and HAL issues.

 

Erm, google is your friend ubt I use the following sysprep commands:

 

sysprep -bmsd

 

followed by

 

sysprep -clean

 

then

 

sysprep -quiet -mini -reseal

 

MY sysprep file will add the computer to the domain but I still rename them when they've finished first boot as I've not configured any autonaming yet and I just get names like 'school-123486'

Posted
MY sysprep file will add the computer to the domain but I still rename them when they've finished first boot as I've not configured any autonaming yet and I just get names like 'school-123486'

 

If you go for the solution suite, it is brilliant for sysprepping. Once it has a configuration stored for a PC, reimaging is as simple as clicking Execute. The machine then names as it should be etc...

Posted

To change the name, all that is needed in the batch file is a line to insert a reg file and the use of reg frag file to change the key with the computer name.

 

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName]

"ComputerName"="THE-NAME-FOR-YOUR-COMP"

Posted

I'm using Ghost (and GhostCast server) v8.

 

We avoid the HAL issue by having separate images for each model of PC, and NewSID from SysInternals gets around cloned SIDs.

 

After a sysprep'ed ghost image is cloned onto a new PC, does Windows do a mini-setup the same way it does after installation via RIS?

 

Also, would prestaging work in this situation?

 

I setup most of our PCs via RIS, but one room of nForce based machines refuse to work with RIS no matter what I do, so these are still done using GhostCasting. I wanted to achieve the same prestaging and domain join you get with RIS, but for the ghosted PCs, if that makes sense.

 

 

Thanks

Posted
I'm using Ghost (and GhostCast server) v8.

 

We avoid the HAL issue by having separate images for each model of PC, and NewSID from SysInternals gets around cloned SIDs.

 

After a sysprep'ed ghost image is cloned onto a new PC, does Windows do a mini-setup the same way it does after installation via RIS?

 

Yes - but you can automate all of it except the naming part (unless you use ghost solution suite, then it'll handle that too).

 

Also, would prestaging work in this situation?

 

I setup most of our PCs via RIS, but one room of nForce based machines refuse to work with RIS no matter what I do, so these are still done using GhostCasting. I wanted to achieve the same prestaging and domain join you get with RIS, but for the ghosted PCs, if that makes sense.

 

I don't know that one - wouldn't see why you'd want to use RIS if you used Ghost...

Posted
You can use the 'netdom' command to do this.

 

How?

 

I can get netdom to join a machine to a domain, but I need a way to rename it first. When I try using netdoms /renamecomputer switch, it fails saying the machine is not joined to a domain.

 

Can netdom only rename machines already joined to a domain? Surely it makes more sense to rename a machine, then join it to the domain? :?

 

 

Thanks

Posted

I used to Ghost with my own AutoIT file in steps.

 

Step 1 - Add auto logon info to run the other autoit files in c:\autoit\autoit3.exe step2.au3 etc etc

 

Step 2 - Used autoit to prompt for a computer name which u type in then it executed newsid.exe /a [computernameVariable] and add new autorun info into registry and remove the old autorun info. (reboot automatically)

 

Step 3 - Obviously removes the old autorun and autologin info and uses netdom to join the domain and put pc in correct OU.

 

I've used this on serveral ghost setups. Works 90% of the time but its a massive time saver when you've got 30-60 workstations to do. I just modify the au3 files from time to time and dump it onto the next machine for ghosting.

Posted
Can netdom only rename machines already joined to a domain?

 

I think that's correct, although the next version of netdom (for W2K8) definitely will rename a non-domain machine.

Posted

Thanks everyone.

 

techyphil:

Your method sounds exactly like what I was trying to achieve, although I hadn't thought of using AutoIT. That's a stroke of genius! :idea:

 

Thanks again.

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...