@ECHO OFF
:check converter.exe
tasklist >list.txt //将所有程序資訊列入list.txt檔案裡面(這裡預設目前目錄)
find /i "converter.exe" list.txt //從list.txt檔案裡查找java.exe這個程序
if "%errorlevel%"=="1" (goto start) else (goto e) //如果程序不存在,執行start處的代碼;反之執行e處的代碼
:e
taskkill /f /im converter.exe //殺掉程序
:start
cls
START startup.bat //開啟程序 要與腳本在同一目錄下
:check cmd.exe //由于上面殺程序後會留下cmd.exe沒有退出,并一起kill cmd.exe
tasklist >list2.txt
find /i "cmd.exe" list2.txt
if "%errorlevel%"=="1" (goto e)
taskkill /f /im cmd.exe
:end
exit
at 12:22 /every:m,t,w,th,f,s,su "D:\converter_station\ftpbat.bat“ 計劃任務
本文轉自crazy_charles 51CTO部落格,原文連結:http://blog.51cto.com/douya/1433485,如需轉載請自行聯系原作者