From LedHed's Wiki
Jump to: navigation, search
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.