<p>Is it possible to change the hostname in Windows 2003 from the command line with out-of-the-box tools?</p>

[{'answer_id': 55004, 'author': 'GEOCHET', 'author_id': 5640, 'author_profile': 'https://Stackoverflow.com/users/5640', 'pm_score': 1, 'selected': False, 'text': '<p>I don\'t know of a command to do this, but you could do it in VBScript or something similar.\nSomthing like:</p>\n\n<pre class="lang-vb prettyprint-override"><code>sNewName = "put new name here" \n\nSet oShell = CreateObject ("WSCript.shell" ) \n\nsCCS = "HKLM\\SYSTEM\\CurrentControlSet\\" \nsTcpipParamsRegPath = sCCS &amp; "Services\\Tcpip\\Parameters\\" \nsCompNameRegPath = sCCS &amp; "Control\\ComputerName\\" \n\nWith oShell \n.RegDelete sTcpipParamsRegPath &amp; "Hostname" \n.RegDelete sTcpipParamsRegPath &amp; "NV Hostname" \n\n.RegWrite sCompNameRegPath &amp; "ComputerName\\ComputerName", sNewName \n.RegWrite sCompNameRegPath &amp; "ActiveComputerName\\ComputerName", sNewName \n.RegWrite sTcpipParamsRegPath &amp; "Hostname", sNewName \n.RegWrite sTcpipParamsRegPath &amp; "NV Hostname", sNewName \nEnd With \' oShell \n\nMsgBox "Computer name changed, please reboot your computer" \n</code></pre>\n\n<p><a href="http://www.tomshardware.com/forum/26545-45-change-computer-name-command-line-registry" rel="nofollow noreferrer">Original</a></p>\n'}, {'answer_id': 55212, 'author': 'Steven Murawski', 'author_id': 1233, 'author_profile': 'https://Stackoverflow.com/users/1233', 'pm_score': 2, 'selected': True, 'text': '<p>The netdom.exe command line program can be used.  This is available from the Windows XP Support Tools or Server 2003 Support Tools (both on the installation CD).</p>\n\n<p>Usage guidelines <a href="https://web.archive.org/web/20170928171940/https://support.microsoft.com/en-us/help/298593/how-to-use-the-netdom-exe-utility-to-rename-a-computer-in-windows-xp" rel="nofollow noreferrer">here</a></p>\n'}, {'answer_id': 55213, 'author': 'axk', 'author_id': 578, 'author_profile': 'https://Stackoverflow.com/users/578', 'pm_score': 1, 'selected': False, 'text': '<p>Here\'s another way of doing it with a WHS script:</p>\n\n<pre class="lang-vb prettyprint-override"><code>Set objWMIService = GetObject("Winmgmts:root\\cimv2")\n\nFor Each objComputer in _\n    objWMIService.InstancesOf("Win32_ComputerSystem")\n\n    objComputer.rename "NewComputerName", NULL, NULL \nNext\n</code></pre>\n\n<p><a href="http://msdn.microsoft.com/en-us/library/aa393056(VS.85).aspx" rel="nofollow noreferrer">Source</a></p>\n'}, {'answer_id': 3738620, 'author': 'Gringo Suave', 'author_id': 450917, 'author_profile': 'https://Stackoverflow.com/users/450917', 'pm_score': 6, 'selected': False, 'text': '<p>The previously mentioned <code>wmic</code> command is the way to go, as it is installed by default in recent versions of Windows.  </p>\n\n<p>Here is my small improvement to generalize it, by retrieving the current name from the environment:</p>\n\n<pre class="lang-dos prettyprint-override"><code>wmic computersystem where name="%COMPUTERNAME%" \n     call rename name="NEW-NAME"\n</code></pre>\n\n<p>NOTE: The command must be given in one line, but I\'ve broken it into two to make scrolling unnecessary.  As @rbeede mentions you\'ll have to reboot to complete the update.</p>\n'}, {'answer_id': 20087946, 'author': 'litao', 'author_id': 2646189, 'author_profile': 'https://Stackoverflow.com/users/2646189', 'pm_score': 4, 'selected': False, 'text': '<p>cmd (command): </p>\n\n<pre class="lang-dos prettyprint-override"><code>netdom renamecomputer %COMPUTERNAME% /Newname "NEW-NAME"\n</code></pre>\n\n<p>powershell (windows 2008/2012):</p>\n\n<pre class="lang-sh prettyprint-override"><code>netdom renamecomputer "$env:COMPUTERNAME" /Newname "NEW-NAME"\n</code></pre>\n\n<p>after that, you need to reboot your computer.</p>\n'}, {'answer_id': 25141066, 'author': 'Swapnil Gangrade', 'author_id': 2257531, 'author_profile': 'https://Stackoverflow.com/users/2257531', 'pm_score': 1, 'selected': False, 'text': '<p>Use below command to change computer hostname remotely , Require system reboot after change..</p>\n\n<p><code>psexec.exe -h -e \\\\\\IPADDRESS -u USERNAME -p PASSWORD netdom renamecomputer CurrentComputerName /newname:NewComputerName /force</code></p>\n'}, {'answer_id': 32301265, 'author': 'codechurn', 'author_id': 107762, 'author_profile': 'https://Stackoverflow.com/users/107762', 'pm_score': 0, 'selected': False, 'text': '<p>If you are looking to do this from Windows 10 IoT, then there is a built in command you can use:</p>\n\n<p><code>setcomputername [newname]</code></p>\n\n<p>Unfortunately, this command does <em>not exist</em> in the full build of Windows 10.</p>\n'}, {'answer_id': 38814390, 'author': 'LaurFromRomania', 'author_id': 6688007, 'author_profile': 'https://Stackoverflow.com/users/6688007', 'pm_score': 1, 'selected': False, 'text': '<p>Why be easy when it can be complicated?\nWhy use third-party applications like netdom.exe when correct interogations is the way?\nTry 2 interogations:</p>\n\n<p><strong>wmic computersystem where caption=\'%computername%\' get caption, UserName, Domain /format:value</strong></p>\n\n<p><strong>wmic computersystem where "caption like \'%%%computername%%%\'" get caption, UserName, Domain /format:value</strong></p>\n\n<p>or in a batch file use loop</p>\n\n<p><strong>for /f "tokens=2 delims==" %%i in (\'wmic computersystem where "Caption like \'%%%currentname%%%\'" get UserName /format:value\') do (echo. UserName- %%i)</strong></p>\n'}]
['https://Stackoverflow.com/questions/54989', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1807/']