Reading a value from a file in a windows batch script

后端 未结 3 2454
陌清茗
陌清茗 2021-02-20 17:57

I\'m trying to read a value from a file and use it in a subsequent command.

I have a file called AppServer.pid which contains the process id of my app serve

3条回答
  •  北恋
    北恋 (楼主)
    2021-02-20 18:31

    If you know the name of the process, as returned from the command tasklist, then you can run taskkill with a filter on the process name, i.e. /FI IMAGENAME eq %process_name%.

    For example, to kill all of the processes named nginx.exe run:

        taskkill /F /FI "IMAGENAME eq nginx.exe"
    

    Which "reads in English": kill all tasks (forcefully if needed via /F) that match the filter /FI "IMAGENAME equals nginx.exe".

提交回复
热议问题