{"id":163,"date":"2021-09-03T01:59:42","date_gmt":"2021-09-03T01:59:42","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/changing-a-batch-files-process-name"},"modified":"2021-09-03T03:03:25","modified_gmt":"2021-09-03T03:03:25","slug":"changing-a-batch-files-process-name","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/windows-xp\/changing-a-batch-files-process-name\/183779.html","title":{"rendered":"changing a batch files process name"},"content":{"rendered":"<p>Hi,<br \/>\nI am trying to find a way to rename, or set<br \/>\nthe name of the process of a batch file. By<br \/>\ndefault the process name is just <a style=\"cursor: help; text-decoration: underline; color: #000000;\">cmd.exe<\/a>. I<br \/>\nwould like to change the name for easier<br \/>\nrecognition. Any suggestions would be<br \/>\nhelpful.<br \/>\n~Eric<\/p>\n<p>The only way I can think of would be:<\/p>\n<p>1. Start the script normally.<br \/>\n2. Copy <a style=\"cursor: help; text-decoration: underline; color: #000000;\">cmd.exe<\/a> to the current directory with the desired name.<br \/>\n3. Restart the script with the copied exexutable.<\/p>\n<p>&lt;untested&gt;<\/p>\n<pre>@echo off\r\nif not \"%~1\"==\"iamsecond\" (\r\n    For %%a in (cmd.exe) do copy \"%%~$path:a\" \"desiredname.exe\"\r\n    start \/b \"\" \"desiredname.exe\" \/c \"%~0\" iamsecond %*\r\n    goto :eof\r\n)\r\nshift\r\n\r\nrem the script goes here\r\n\r\ndel \"desiredname.exe\"\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Thank you for your quick response. I don&#8217;t completely<br \/>\nunderstand what you want me to do. I tried a few different<br \/>\nthings, but could not get the exe to run my code. the exe does<br \/>\nhave its own process name though. also, it would be a lot easier<br \/>\nif it were possible to change the name in the batch file inside<br \/>\nitself.<\/p>\n<p>There is no way to change the process name under batch script, in fact I&#8217;m not sure if it&#8217;s even possible at all&#8230;.<\/p>\n<p>I gave it a quick test and it works fine to start the script as another process for me. I think a variation of this quick hack may be the only option&#8230;..<\/p>\n<p>I tweaked it a little so it will actually delete the copy of <a style=\"cursor: help; text-decoration: underline; color: #000000;\">cmd.exe<\/a>.<\/p>\n<pre>@echo off\r\nif not \"%~1\"==\"iamsecond\" (\r\n    For %%a in (cmd.exe) do copy \"%%~$path:a\" \"desiredname.exe\"&gt;nul\r\n    start \/b \"\" \"desiredname.exe\" \/c \"%~0\" iamsecond %*\r\n    goto :eof\r\n)\r\nshift\r\n\r\nrem the script goes here\r\necho Hello! I'm running Under the process name \"desiredname.exe\"\r\necho The title is a lie!\r\npause\r\ntitle It was lying! No More!\r\npause\r\n\r\n\r\nstart \/b cmd \/c del \"desiredname.exe\"\r\ngoto :eof\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","template":"","meta":{"inline_featured_image":false,"iawp_total_views":5},"question-category":[76],"question_tags":[],"class_list":["post-163","question","type-question","status-publish","hentry","question-category-windows-xp"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question\/163","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question"}],"about":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/types\/question"}],"author":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/comments?post=163"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=163"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=163"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}