Sponsored Links

A task as simple as renaming a Domain PC remotely would seem like a simple task. For whatever reason, there is really no good way of doing this. After searching through various scripts to do this job, I finally found a pretty good way of doing this. All it requires is a little vb script and netdom.exe from the Windows Support Tools.

First off, you will need to download the Windows XP Support tools from here

Install the support tools to the default path.

After it is installed, we are going to create a vb script.
Open Notepad and copy and paste the following text into Notepad

COPY EVERYTHING BELOW THIS LINE
---------------------------------------------------------------------------------------
'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","Windows 2k3 Netdom Rename Script")
sNewCname = InputBox("Enter computers new name","Windows 2k3 Netdom Rename Script")

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

-----------------------------------------------------------------------------------------
COPY EVERYTHING ABOVE THIS LINE

After you copy and paste the text into notepad, replace the capitalized text on the last line to fit your network. For the password fields, if you do not want to store passwords in clear text in the vbs file, replace PASSWORD with *. Save the file as Remotely_Change_Computername.vbs and save it in a location you will remember.

When you run the script it will prompt you for the current computername, type in the current computer name and press enter.
It will then ask you for the name you want to change the computername to, type in what you want to change it to and press enter.
If you stored the passwords in the vbs file, it will automatically rename the computer, if you put the * in the place of the password in the vbs file it will prompt you for the passwords to the usernames you entered. After completing these steps, the remote machine will be renamed.

Note: You can just run the netdom.exe file from the command line using netdom.exe renamecomputer OldName /NewName /userd:DOMAIN\ADMINISTRATOR /passwordd:PASSWORD /usero:DOMAIN\ADMINISTRATOR /passwordo:PASSWORD /force
I just like to have a few click access without running to a command prompt and remembe which switches to add to complete my task.

NOTE: THIS INFORMATION IS PROVIDED "AS IS" WITH NO WARRANTIES EXPRESSED OR IMPLIED.