Scripts Thread, Rename a computer remotely in Coding and Web Development; I have posted this in the blogs as well. I thought i would put it here as well, sometimes users ...
5th February 2012, 11:12 PM #1
Rename a computer remotely
I have posted this in the blogs as well. I thought i would put it here as well, sometimes users miss things in the blog.
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 nothing additional is required.
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 ")
Thanks to FN-GM from:
pooley (5th February 2012)
IDG Tech News
By fafster in forum How do you do....it?
Last Post: 14th June 2010, 04:01 PM
By msnriggs in forum Scripts
Last Post: 20th January 2010, 07:21 AM
By FN-GM in forum Windows 7
Last Post: 14th September 2009, 09:43 PM
By marvin in forum Windows
Last Post: 23rd February 2009, 11:01 AM
By Benji1 in forum Windows
Last Post: 8th July 2006, 09:39 AM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)