批处理-- 查询进程,杀进程,启动pythond程序,任务计划程序
@echo off wmic process where caption="python.exe" get processid,commandline | findstr "main.py" > c:\psfind.txt set /P ps=<c:\psfind.txt ::echo %ps% set ps=%ps:~-20% ::echo %ps% set "ps=%ps: =%" taskkill /F /PID %ps% cd /d C:\www\TACƽ̨\md-gateway\ @python main.py pause
-- taskkill /f /t /im python.exe 杀死指定进程
set ps=%ps:~-20% 字符串操作,从后截取20长度
set "ps=%ps: =%" 去除空格
执行多个bat
cd /d C:\wwwroot\tv-service # 启动 start "server-1" cmd /k call restart_1.bat #暂停2s -n 为s+1 ping -n 3 127.0.0.1>nul start "server-2" cmd /k call restart_2.bat #暂停2s ping -n 6 127.0.0.1>nul # node start "node-server-2" cmd /k call restart_3.bat start "node-server-2" cmd /k call restart_4.bat ping -n 20 127.0.0.1>nul #clear cmd taskkill /f /im cmd.exe exit
@echo off wmic process where caption="python.exe" get processid,commandline | findstr "main.py" > c:\psfind.txt set /P ps=<c:\psfind.txt ::echo %ps% set ps=%ps:~-20% ::echo %ps% set "ps=%ps: =%" taskkill /F /PID %ps% cd /d C:\www\TACƽ̨\md-gateway\ @python main.py pause
本文来自博客园,作者:至道中和,转载请注明原文链接:https://www.cnblogs.com/voidobject/p/16492276.html