Question

Locked

Can't use netdom

By Spector ·
Hi. I'm trying to rename a computer remote using netdom but can't get it to work. I use the following examples:
http://support.microsoft.com/default.aspx?scid=kb;en-us;298593&sd=tech

and I have also tried this script:

'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\admin /passwordd:pass /usero:admin /passwordo:pass /force ")

But nothing works for me. When I run the example on the microsoft link it shows me the syntax of netdom. Running the script says wrong login/pass.
I've change "domain" too our real domain name and change the "user/pass" to our real user/pass.
What do I do wrong?

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

WbemScripting.SWbemLocator

by dan.cox In reply to Can't use netdom

We use a scrtipt to rename our PC's that seems to work great for us.
See below for what we do.

Set objWMILocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objWMILocator.ConnectServer(strComputer, strNamespace)
Set colComputers = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For Each objComputer in colComputers
Result = ObjComputer.Rename(strNewName)
Next

If Result = 0 Then
' Update registry entries based on the new computer name
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
objReg.SetStringValue HKEY_CLASSES_ROOT,"CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}","LocalizedString" ,"My Computer " & strNewName
objReg.SetStringValue HKEY_LOCAL_MACHINE,"SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName","ComputerName" , strNewName

Back to Desktop Forum
2 total posts (Page 1 of 1)  

Hardware Forums