0
我做了一個重啓2個服務的bat文件,我讓它在任務調度器中運行。如果我正常運行bat文件,我可以看到它作爲bat文件登錄到當前目錄。但如果我通過任務調度程序運行它,我可以看到蝙蝠運行,就像在服務窗口中,我可以看到服務重新啓動,但它不記錄任何東西....有誰知道問題是什麼?從任務調度程序運行時,Bat文件不記錄?
這是在windows server 2008 r2 64位。
感謝
@echo off
SET waittimeseconds_sp_fix=15
SET logfilename_sp_fix="SPSearchFix.log"
echo %date% %time% - Restart starting >> %logfilename_sp_fix%
net stop SPTimerV4 >> %logfilename_sp_fix% 2>&1
if ERRORLEVEL 0 (
echo %date% %time% - WORKED - Stopped timer service >> %logfilename_sp_fix%
) ELSE (
echo %date% %time% - FAILED - Stopped timer service >> %logfilename_sp_fix%
exit
)
timeout %waittimeseconds_sp_fix%
net stop osearch14 >> %logfilename_sp_fix% 2>&1
if ERRORLEVEL 0 (
echo %date% %time% - WORKED - Stopped search service >> %logfilename_sp_fix%
) ELSE (
echo %date% %time% - FAILED - Stopped search service >> %logfilename_sp_fix%
exit
)
timeout %waittimeseconds_sp_fix%
net start SPTimerV4 >> %logfilename_sp_fix% 2>&1
if ERRORLEVEL 0 (
echo %date% %time% - WORKED - Started timer service >> %logfilename_sp_fix%
) ELSE (
echo %date% %time% - FAILED - Started timer service >> %logfilename_sp_fix%
exit
)
timeout %waittimeseconds_sp_fix%
net start osearch14 >> %logfilename_sp_fix% 2>&1
if ERRORLEVEL 0 (
echo %date% %time% - WORKED - Started search service >> %logfilename_sp_fix%
) ELSE (
echo %date% %time% - FAILED - Started search service >> %logfilename_sp_fix%
exit
)
timeout %waittimeseconds_sp_fix%
echo %date% %time% - Restart completed >> %logfilename_sp_fix%
echo. >> %logfilename_sp_fix%
echo. >> %logfilename_sp_fix%
echo. >> %logfilename_sp_fix%
echo. >> %logfilename_sp_fix%
echo. >> %logfilename_sp_fix%
echo. >> %logfilename_sp_fix%
我想通了,它出於某種原因登錄到system32文件夾,但絕對路徑工作。 – omega
嘗試爲日誌文件設置絕對路徑,如C:\ temp \ foo.log – Marged