Change process name when launched as batch file

后端 未结 4 2017
长发绾君心
长发绾君心 2020-12-19 04:33

I\'m working on a monitoring system called \"Nagios\" which monitors services for UNIX and WINDOWS servers. Problem is WINDOWS services that are launched by batch files are

相关标签:
4条回答
  • 2020-12-19 04:50

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

    @echo off
    title MyBatchTitle
    ...
    
    0 讨论(0)
  • 2020-12-19 05:12

    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.

    0 讨论(0)
  • 2020-12-19 05:13

    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.

    0 讨论(0)
  • 2020-12-19 05:14

    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

0 讨论(0)
提交回复
热议问题