{"id":419,"date":"2023-03-25T11:35:18","date_gmt":"2023-03-25T11:35:18","guid":{"rendered":"https:\/\/xuan.co.uk\/?p=419"},"modified":"2025-08-22T12:23:08","modified_gmt":"2025-08-22T12:23:08","slug":"rename-machine-name-in-dos","status":"publish","type":"post","link":"https:\/\/xuan.co.uk\/?p=419","title":{"rendered":"Rename machine name in DOS"},"content":{"rendered":"<p>echo off<br \/>\ncls<\/p>\n<p>:: This batch file will rename the computer using the service tag in BIOS.<\/p>\n<p>:: find out what path the batch file is in<br \/>\n:: set batch_path=%~dp0<\/p>\n<p>:: change drive<br \/>\n:: %batch_path:~0,2%<\/p>\n<p>:: crop the last character and cd into it<br \/>\n:: cd %batch_path:~0,-1%<\/p>\n<p>:: clear screen show bitlocker status<br \/>\n:: cls<\/p>\n<p>:: WMIC computersystem where caption=&#8217;current_pc_name&#8217; rename new_pc_name<\/p>\n<p>:: pipe machine service tag to serial.txt so that later we can reverse pipe into the variable that used to name the capture file<br \/>\nwmic bios get serialnumber | find \/v &#8220;SerialNumber&#8221; &gt; %temp%\/serial.txt<\/p>\n<p>::pipe in serial<br \/>\nset \/p serial=&lt;%temp%\\serial.txt<\/p>\n<p>:: trim spaces<br \/>\nset serial_temp=%serial: =%<\/p>\n<p>:: store serial<br \/>\nset serial=%serial_temp%<\/p>\n<p>set current_name=%hostname%<\/p>\n<p>@echo.<br \/>\n@echo *************************************************************************************<br \/>\n@echo &#8212; Renaming machine from %computername% to XXXXX%serial% &#8212;<br \/>\n@echo *************************************************************************************<\/p>\n<p>wmic computersystem where &#8220;name=&#8217;%computername%'&#8221; call rename name=XXXXX%serial%<\/p>\n","protected":false},"excerpt":{"rendered":"<p>echo off cls :: This batch file will rename the computer using the service tag in BIOS. :: find out what path the batch file is in :: set batch_path=%~dp0 :: change drive :: %batch_path:~0,2% :: crop the last character and cd into it :: cd %batch_path:~0,-1% :: clear screen <a class=\"more-link\" href=\"https:\/\/xuan.co.uk\/?p=419\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[81],"class_list":["post-419","post","type-post","status-publish","format-standard","hentry","category-tech-tips","tag-cmd"],"_links":{"self":[{"href":"https:\/\/xuan.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/419","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xuan.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xuan.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xuan.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xuan.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=419"}],"version-history":[{"count":2,"href":"https:\/\/xuan.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/419\/revisions"}],"predecessor-version":[{"id":486,"href":"https:\/\/xuan.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/419\/revisions\/486"}],"wp:attachment":[{"href":"https:\/\/xuan.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=419"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xuan.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=419"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xuan.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=419"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}