Executing a batch file with a different process name

I have 6 different scripts that I run together at the same time. The problem is that it is difficult to distinguish them in the Windows task manager, because the process is always just cmd.exe . I was wondering if there is a way to change the process name for the script package for something else so that each script is more identifiable.

I have done a lot of research on this topic so far, and the only thing I have is to create a copy of cmd.exe in system32, which has a different name, one of my preferences, The problem is that I'm not sure how to get my bash script to use this new executable with a different name, not the default cmd.exe

Requirement: Only the built-in Windows features must be used. I do not want to install any other programs, if possible.

+4
source share
2 answers

You can do this using the routine below. The reason for the first goto is that you do not fall into the routine when you are done. I include another FOR loop to iterate over the list of file names to check. Let's start this work first.

Your existing bat file goes here
CALL :IsitRunning "SomeFileName"
The rest of your existing bat file goes here
GOTO :eof

:IsitRunning
REM 1=Filename
FOR /F "delims=" %%A in ('WMIC PROCESS WHERE NAME^='CMD.EXE' LIST FULL ^| FINDSTR /I "%~1" ^| FINDSTR /I /V WMIC') DO ECHO(%~1 is running
GOTO :eof

Or you can run this command from the CMD prompt.

wmic process WHERE NAME='cmd.exe' list full | findstr /i "SomeFileName.bat"
+2
source

You can see the command line in the task manager, enable it in the "View" menu - select the columns.

, . , - .

+1

All Articles