View RSS Feed

FN-GM

Rename a computer remotely

Rate this Entry
by , 5th February 2012 at 10:08 PM (18380 Views)
From time to time we need to rename computers on the domain. The computers can sometimes be in a locked room, in a remote site or you simply cant be bothered visiting them.

This code below will allow you to rename computers on the domain form the comfort of your own desk. Once you have entered you old name and your new name the computer concerned will automatically reboot and your all done! All you have to do is make sure nobody is using the machine and that the new computer name is available in AD.

If you are still running Windows XP you will have to install the Windows XP Support Tools. If you are on Vista or Windows 7 you will need to install the RSAT tools.

Just copy the below code into a notepad file. Set the username and password of an account with appropriate permissions, then save the file as a .vbs then your good to go! Just run the new file and you will see prompts for the new name and the old name.

Code:
'On Error Resume Next

'open the file system object
Set oFSO = CreateObject("Scripting.FileSystemObject")
set WSHShell = wscript.createObject("wscript.shell")

Dim sNewCname     'Variable to hold Computer Name you enter in the inputbox
Dim sOldCname        'computers current name

'First param is message text, second is message title
sOldCname = InputBox("Enter computers current name","Computer Rename Utility")
sNewCname = InputBox("Enter computers new name","Computer Rename Utility")

Call WSHShell.Run("cmd.exe /K netdom renamecomputer " & sOldCname & " /newname:" & sNewCname & " /userd:DOMAIN\USER /passwordd:PASSWORD /usero:DOMAIN\USER /passwordo:PASSWORD /force /reboot:5 ")

Updated 27th June 2013 at 04:08 PM by FN-GM

Categories
Uncategorized

Comments

  1. TheLibrarian's Avatar
    IIRC you need the Windows 7 RSAT installed before you have access to "netdom".
  2. FN-GM's Avatar
    Thanks, i didnt know that.
  3. TheLibrarian's Avatar
    You are welcome.

Trackbacks

Total Trackbacks 0
Trackback URL: