dos批处理(bat)运行exe
@echo off SETLOCAL ENABLEDELAYEDEXPANSION
REM 延迟环境变量扩展 color E echo operate:1.start启动 2.stop停止 3.exit退出 :loop set /p a=please enter operate: for %%i in ( MessagePush.ClientHost.exe MessagePush.PushHost.exe ) do ( set j=%%i set k=!j:~0,-4! if %a%==3 ( exit ) else ( if %a%==2 ( tasklist|find /i "!k!"&& taskkill /t /im !j!|| echo %time:~,-3% !j! already killed! echo !j! has killed ) else ( if %a%==1 ( tasklist|find /i "!k!"&& echo %time:~,-3% !j! already started!|| start "" "D:\work\PushTrans2.0\!k!\bin\Release\!j!" echo !j! has started ) else ( echo caution:please enter right operate goto loop ) ) ) ) pause>nul rem 不显示“请按任意键继续. . .”