我有一个从CMD运行的脚本正常运行,但是当我从任务调度程序运行它时,尽管它按预期执行所有操作,但脚本状态挂在“运行中”。
下面是脚本:
@echo OFF
tasklist /FI "IMAGENAME eq utorrent.exe" 2>NUL | find /I /N "utorrent.exe">NUL
if "%ERRORLEVEL%"=="0" (echo UTorrent is running nothing to do) ELSE (
echo UTorrent is not running, starting Utorrent!
start C:\Users\Adonis\AppData\Roaming\uTorrent\uTorrent.exe
)
tasklist /FI "IMAGENAME eq steam.exe" 2>NUL | find /I /N "steam.exe">NUL
if "%ERRORLEVEL%"=="0" (echo Steam is running nothing to do) ELSE (
echo Steam is not running, starting Steam!
start X:\Games\SteamLibrary\Steam.exe
)
exit有人能告诉我为什么会发生这种情况吗?也就是说,为什么脚本通过调度程序停留在运行状态?
有问题的操作系统是windows 8。它被设置为仅当用户登录并具有最高权限时才运行。
谢谢!
发布于 2013-04-21 16:05:48
尝试使用/B参数启动应用程序,以避免停止脚本的执行。
此外,我还改进了代码的语法:
@echo OFF
(Tasklist /FI "IMAGENAME eq utorrent.exe" | find /I "utorrent.exe">NUL && (
Echo: UTorrent is running nothing to do)
) || (
Echo: UTorrent is not running, starting Utorrent!
Start /B "" "C:\Users\Adonis\AppData\Roaming\uTorrent\uTorrent.exe"
)
(Tasklist /FI "IMAGENAME eq steam.exe" | find /I "steam.exe">NUL && (
Echo: Steam is running nothing to do)
) || (
Echo: Steam is not running, starting Steam!
Start /B "" "X:\Games\SteamLibrary\Steam.exe"
)
Exithttps://stackoverflow.com/questions/16120843
复制相似问题