+ Post New Thread
Results 1 to 14 of 14
Windows Thread, Rename a PC from a batch file - Any ideas? in Technical; Hi, I want to write a couple of batch files that will be run automatically after a PC has been ...
  1. #1
    MrLudwig's Avatar
    Join Date
    Jul 2005
    Location
    Behind You!
    Posts
    102
    Thank Post
    42
    Thanked 6 Times in 6 Posts
    Rep Power
    20

    Rename a PC from a batch file - Any ideas?

    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

  2. #2

    localzuk's Avatar
    Join Date
    Dec 2006
    Location
    Minehead
    Posts
    17,684
    Thank Post
    516
    Thanked 2,453 Times in 1,899 Posts
    Blog Entries
    24
    Rep Power
    833

    Re: Rename a PC from a batch file - Any ideas?

    Why not use sysprep before you ghost the machines? http://support.microsoft.com/kb/302577

    What version of ghost are you using?

  3. #3
    mrforgetful's Avatar
    Join Date
    May 2006
    Posts
    1,637
    Thank Post
    7
    Thanked 15 Times in 15 Posts
    Rep Power
    22

    Re: Rename a PC from a batch file - Any ideas?

    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'

  4. #4

    localzuk's Avatar
    Join Date
    Dec 2006
    Location
    Minehead
    Posts
    17,684
    Thank Post
    516
    Thanked 2,453 Times in 1,899 Posts
    Blog Entries
    24
    Rep Power
    833

    Re: Rename a PC from a batch file - Any ideas?

    Quote Originally Posted by mrforgetful
    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...

  5. #5
    MicrodigitUK's Avatar
    Join Date
    May 2007
    Location
    Wiltshire
    Posts
    334
    Thank Post
    37
    Thanked 55 Times in 51 Posts
    Rep Power
    24

    Re: Rename a PC from a batch file - Any ideas?

    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\Contro l\ComputerName\ActiveComputerName]
    "ComputerName"="THE-NAME-FOR-YOUR-COMP"

  6. #6
    MrLudwig's Avatar
    Join Date
    Jul 2005
    Location
    Behind You!
    Posts
    102
    Thank Post
    42
    Thanked 6 Times in 6 Posts
    Rep Power
    20

    Re: Rename a PC from a batch file - Any ideas?

    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

  7. #7

    localzuk's Avatar
    Join Date
    Dec 2006
    Location
    Minehead
    Posts
    17,684
    Thank Post
    516
    Thanked 2,453 Times in 1,899 Posts
    Blog Entries
    24
    Rep Power
    833

    Re: Rename a PC from a batch file - Any ideas?

    Quote Originally Posted by MrLudwig
    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...

  8. #8
    mrforgetful's Avatar
    Join Date
    May 2006
    Posts
    1,637
    Thank Post
    7
    Thanked 15 Times in 15 Posts
    Rep Power
    22

    Re: Rename a PC from a batch file - Any ideas?

    Also Sysprep itself gets the SID sorted so why do you need other software for that?

    *remembers back to the day of Windows 98 and having to run Ghostwalker on every PC*

  9. #9

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,804
    Thank Post
    110
    Thanked 583 Times in 504 Posts
    Blog Entries
    1
    Rep Power
    224

    Re: Rename a PC from a batch file - Any ideas?

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

  10. #10
    MrLudwig's Avatar
    Join Date
    Jul 2005
    Location
    Behind You!
    Posts
    102
    Thank Post
    42
    Thanked 6 Times in 6 Posts
    Rep Power
    20

    Re: Rename a PC from a batch file - Any ideas?

    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

  11. #11

    Join Date
    Mar 2007
    Posts
    323
    Thank Post
    6
    Thanked 7 Times in 6 Posts
    Rep Power
    17

    Re: Rename a PC from a batch file - Any ideas?

    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.

  12. #12

    Join Date
    Jan 2006
    Location
    Surburbia
    Posts
    2,178
    Thank Post
    74
    Thanked 307 Times in 243 Posts
    Rep Power
    115

    Re: Rename a PC from a batch file - Any ideas?

    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.

  13. #13
    MrLudwig's Avatar
    Join Date
    Jul 2005
    Location
    Behind You!
    Posts
    102
    Thank Post
    42
    Thanked 6 Times in 6 Posts
    Rep Power
    20

    Re: Rename a PC from a batch file - Any ideas?

    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.

  14. #14
    mark's Avatar
    Join Date
    Jun 2005
    Posts
    3,966
    Thank Post
    248
    Thanked 49 Times in 45 Posts
    Blog Entries
    2
    Rep Power
    46

    Re: Rename a PC from a batch file - Any ideas?

    there's a command line utility to name/rename machines 'off domain' here

    see /? for instructions

SHARE:
+ Post New Thread

Similar Threads

  1. Rename a batch of files all at once.
    By Kyle in forum How do you do....it?
    Replies: 10
    Last Post: 19th November 2009, 06:31 AM
  2. executing a random command in a batch file
    By Halfmad in forum Scripts
    Replies: 12
    Last Post: 6th November 2007, 09:25 PM
  3. batch file to shutdown PCs
    By macca in forum Windows
    Replies: 5
    Last Post: 3rd May 2007, 09:20 AM
  4. Replies: 4
    Last Post: 23rd March 2006, 06:27 AM
  5. batch file help
    By beeswax in forum Scripts
    Replies: 9
    Last Post: 3rd March 2006, 07:48 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •