Change process name when launched as batch file

依然范特西╮ 提交于 2019-12-01 05:16:30

You can run batch file as windows service to make a process name. You can set what to happen on start and on stop. You can kill the service using its PID.

C# Tutorial to create batch file as windows service.

You can't change the name of the process. If you need to distinguish between the processes then I would suggest you use their process ID rather than their name.

You can do this with following batch

  • Rename-cmd.bat
    echo off
    set program=c:\Windows\system32\cmd.exe
    set alias_name=%1
    set alias_path=%~dp0
    set batch_file=%2
    set alias=%alias_path%%alias_name%.exe
    call :find_args %*
    call :make_link %program% %alias%
    %alias% /C %batch_file% %args%
    :find_args
    set args=
    shift
    shift
    :loop
      if [%1] == [] goto :eof
      set args=%args% %1
      shift
      goto :loop
    :make_link
      copy %1 %2
    

    HOW TO USE

    Rename-cmd.bat NAME_OF_CMD_IN_TSKMGR BATCH_YOU_WANT_TO_START

  • DOS has a wonderful command called title - would seem to fit

    @echo off
    title MyBatchTitle
    ...
    
    易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
    该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!