本帖最後由 bentse369 於 2016-7-14 17:58 編輯
小弟有關WINDOWS 上的CMD 唔識,請求各大神指點。
要寫一個BATCH FILE, 裡面係大概有3~5 個SERVICES需要關閉,並每一個SERVICES 關閉時間隔距 5 sec 左右,其後一定要確定全部services 闗閉後,執行 "方法1",否則嘗試 關閉5次也不成功後,執行"方法2"
小弟大約寫左CMD如下,但唔成功:
********************************************************************
@echo off
set loopcount=5
:loop
echo Retry to stop services
net stop <Services name 1>
timeout /t 5
net stop <Services name 2>
timeout /t 5
net stop <Services name 3>
timeout /t 5
net stop <Services name 4>
timeout /t 5
set /a loopcount=loopcount-1
if /I ( sc query "Services name 4" |findstr /i "stopped" goto exitloop
) else (
if %loopcount% ==0 goto failureloop )
TIMEOUT /t 6
goto loop
:exitloop //方法1
echo Successful
:failureloop //方法2
echo failed
***************************************************************
請指教 |