changing a batch files process name

March 18, 2010 at 18:25:45
Specs: Windows 7, xp
Hi,
I am trying to find a way to rename, or set
the name of the process of a batch file. By
default the process name is just cmd.exe. I
would like to change the name for easier
recognition. Any suggestions would be
helpful.
~Eric

See More: changing a batch files process name

Report •


#1
March 18, 2010 at 19:01:40
The only way I can think of would be:

1. Start the script normally.
2. Copy cmd.exe to the current directory with the desired name.
3. Restart the script with the copied exexutable.

<untested>

@echo off
if not "%~1"=="iamsecond" (
    For %%a in (cmd.exe) do copy "%%~$path:a" "desiredname.exe"
    start /b "" "desiredname.exe" /c "%~0" iamsecond %*
    goto :eof
)
shift

rem the script goes here

del "desiredname.exe"


Report •

#2
March 18, 2010 at 19:34:34
Thank you for your quick response. I don't completely
understand what you want me to do. I tried a few different
things, but could not get the exe to run my code. the exe does
have its own process name though. also, it would be a lot easier
if it were possible to change the name in the batch file inside
itself.

Report •

#3
March 18, 2010 at 22:11:10
There is no way to change the process name under batch script, in fact I'm not sure if it's even possible at all....

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.....

I tweaked it a little so it will actually delete the copy of cmd.exe.

@echo off
if not "%~1"=="iamsecond" (
    For %%a in (cmd.exe) do copy "%%~$path:a" "desiredname.exe">nul
    start /b "" "desiredname.exe" /c "%~0" iamsecond %*
    goto :eof
)
shift

rem the script goes here
echo Hello! I'm running Under the process name "desiredname.exe"
echo The title is a lie!
pause
title It was lying! No More!
pause


start /b cmd /c del "desiredname.exe"
goto :eof


Report •
Related Solutions


Ask Question