我有一個windows批處理文件,它調用另一個文件Services,它具有需要重新啓動的服務和機器的列表,但其中一個服務不需要啓動週末。有誰知道我可以如何在服務文件中包含%dow%函數然後調用基於dow的服務? PS - 它調用另一個批處理文件STOPANDWAIT,它確保服務尚未運行。在/ F語句的批處理文件中加入dow
這裏是我的代碼:
:start_services
set SECTION=start_services
REM We will try to start all services
echo.
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo Starting services
echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
%TIME_STAMP% BEFORE Starting services >> %TIMETRAC_FILE%
REM Make sure the file that contains the services to be stopped and started actually exists
if not exist %SERVICES_FILE% (
%TIME_STAMP% Services file not found. >> %TIMETRAC_FILE%
echo Services file not found.
goto ERROR_FOUND
)
for /F "tokens=1,2* delims=," %%i in (%SERVICES%) do (
%TIME_STAMP% Starting %%i on %%j >> %TIMETRAC_FILE%
@echo Calling StartServiceAndWait for %%i on %%j
call StartServiceAndWait %%j %%i
%TIME_STAMP% Starting %%i Done >> %TIMETRAC_FILE%
)
%TIME_STAMP% AFTER Starting services >> %TIMETRAC_FILE%
if "%END_TAG%" == "start_services" goto PARTIAL_SUCCESS
我SERVICES%%文件看起來像這樣:
"EMSXComplianceService",\\bosxiptest
"Mxs.Xom",\\bosxiptest
"Mfs.Xom.Emsx",\\bosxiptest
"Mxs.Xom",\\bosxiptest
"Mxs.Xns",\\bosxiptest
"Mfs Wrangler Messanger",\\bosxiptest
,我確實有星期三設置爲
日等全球%的Dow%預先感謝您!
謝謝!
喜@Magoo - 非常感謝你的幫助。當我運行這一點,我的批處理說ELSE不被視爲一個有效的命令,我失敗了。我的服務文件是非常簡單的,現在看起來是這樣的:週一週二週三週四週五] 「EMSXComplianceService」,\\ bosxiptest **哪裏有服務,服務器**這種做法是非常接近我所期待的,如果我可以調整它,我會做。再次感謝你的幫助! –