我正在做一个批处理脚本停止一些服务,但是我会在第二的syntax is incorrect
错误这在循环中serviceList.TEMP
命令的语法不正确:for循环批量
setlocal EnableDelayedExpansion
setlocal enableExtensions
::queryex output file
sc queryex>services.TEMP
find /i /N "DISPLAY_NAME: Hotspot" services.TEMP>tmp1.TEMP
FOR /F "skip=2" %%G in (tmp1.TEMP) do (
set num=%%G
set num=!num:~1,3!
echo !num!>serviceList.TEMP
)
FOR %%X in (serviceList.TEMP) do (
set /a "SKIP_LINES=%%G+7"
set secondForFilter="skip=%SKIP_LINES%"
FOR /F %secondForFilter% %%Z in (services.TEMP) do (
call debug.cmd REM debug.cmd -> echo debug pause>nul
set serv=%%Z
set "serv=!serv: =!" REM Extract PID
set "serv=!serv::=!" REM Extract PID
set procID=!serv!
taskkill /pid %procID% /f >>debug.txt 2>>debug.txt
goto secondLoopEnd
)
:secondLoopEnd
)
del /S *.TEMP >>debug.txt 2>>debug.txt
我想这是在('services.TEMP)中执行'FOR/F%secondForFilter%%% Z'('? – npocmaka
** 1 **。阅读有关命令中的[':label'或':: label-like comment' (')'圆括号](http://stackoverflow.com/a/32147995/3439404)。** 2 **。检查'%% G'循环的右括号。 – JosefZ