Jump to content
  • entries
    14
  • comments
    21
  • views
    263

Rename a computer remotely


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.

 

'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 ")

Edited by FN-GM

4 Comments


Recommended Comments

Guest TheLibrarian

Posted

IIRC you need the Windows 7 RSAT installed before you have access to "netdom".
FN-GM

Posted

Thanks, i didnt know that.
Guest TheLibrarian

Posted

You are welcome. :)
Jaan

Posted

Just tested this works fine for us.

 

Is there a way to get this to prompt for the domain credentials as opposed to having them stored in plain text?

 

cheers for any input.

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...