Hi,
Has anyone figured out how to change computer name via script?
Ideally I would like to compile the script and pass it a variable at runtime that contains the new hostname.
run>ChangeComputerName.exe mynewmachinename
Thanks in advance,
Bob
change computername via script with variables
Moderators: JRL, Dorian (MJT support)
- CyberCitizen
- Automation Wizard
- Posts: 724
- Joined: Sun Jun 20, 2004 7:06 am
- Location: Adelaide, South Australia
Re: change computername via script with variables
wmic computersystem where name="%computername%" call rename name="Computer-Name"
Search the forums there is an example of passing variables via command line on compiled executables.
Search the forums there is an example of passing variables via command line on compiled executables.
FIREFIGHTER
Re: change computername via script with variables
Excellent! thank you for your help.
To "pay it forward" here is my full script and a few notes...
computername below is automatically picked up by WMIC, do not set it as a MS variable.
NewHostName below is passed as a parameter when the compiled macro EXE is run. See note above.
To change the computername to MyNewComputerName run this with a command line parameter:
RenamePCandReboote.exe /NewHostName=MyNewComputerName
Let>RP_Admin=1
Run>%SYS_NATIVE%\cmd.exe /c wmic computersystem where name="%computername%" call rename name="%NewHostName%"
wait>2
//restart computer, do not force it
ShutDownWindows>1
To "pay it forward" here is my full script and a few notes...
computername below is automatically picked up by WMIC, do not set it as a MS variable.
NewHostName below is passed as a parameter when the compiled macro EXE is run. See note above.
To change the computername to MyNewComputerName run this with a command line parameter:
RenamePCandReboote.exe /NewHostName=MyNewComputerName
Let>RP_Admin=1
Run>%SYS_NATIVE%\cmd.exe /c wmic computersystem where name="%computername%" call rename name="%NewHostName%"
wait>2
//restart computer, do not force it
ShutDownWindows>1