(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Wmic ComputerSystem WHERE Name=%ComputerName% call Rename Name="New-Hostname"
Use double quotes if the hostname has a dash ( - ) in it.
This method also also accepts environment variables.