Trying to rename a computer via the netdom command and force a reboot

Posted by user57020 on Server Fault See other posts from Server Fault or by user57020
Published on 2010-10-13T15:29:47Z Indexed on 2012/04/01 11:32 UTC
Read the original article Hit count: 342

Filed under:

Why doesn't this work? it looks like it will but nothing happens.

Option Explicit

Dim wshNetwork
Dim wshShell
Dim PCname
Dim Newname

Set wshNetwork = WScript.CreateObject("WScript.Network")
Set wshShell = WScript.CreateObject("WScript.Shell")

PCname = InputBox("Type in the name of the pc you want to rename")
Newname = InputBox("Type in the name of the new pc name")

wshShell.run("netdom renamecomputer " &PCname& " /NewName:"&Newname& " /reboot:00 " )
'MsgBox("netdom renamecomputer " &PCname& " /NewName:"&Newname& " /reboot:00 /y")

© Server Fault or respective owner

Related posts about scripting