Rename a computer remotely
by, 5th February 2012 at 10:08 PM (18540 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 ")
Total Trackbacks 0