Batch file 批处理脚本忽略%ERRORLEVEL%或使用以前设置的
我编写了一个批处理脚本,以确定特定进程是否在计算机上运行:Batch file 批处理脚本忽略%ERRORLEVEL%或使用以前设置的,batch-file,process,errorlevel,Batch File,Process,Errorlevel,我编写了一个批处理脚本,以确定特定进程是否在计算机上运行: for /f %%a in (computers.txt) do ( PsList.exe \\%%a -e "process" > result.txt Find /i "found" < result.txt IF "%ERRORLEVEL%" == "0" echo %%a >> Computers_without_process.csv ) 用于
for /f %%a in (computers.txt) do (
PsList.exe \\%%a -e "process" > result.txt
Find /i "found" < result.txt
IF "%ERRORLEVEL%" == "0" echo %%a >> Computers_without_process.csv
)
用于(computers.txt)中的/f%%a(
PsList.exe\\%%a-e“进程”>result.txt
查找/i“找到”>计算机没有\u process.csv
)
我确实找到了/I“找到了”setlocal enableDelayedExpansion
for /f %%a in (computers.txt) do (
PsList.exe \\%%a -e "process" > result.txt
Find /i "found" < result.txt
IF "!ERRORLEVEL!" == "0" echo %%a >> Computers_without_process.csv
)
setlocal enableDelayedExpansion
for /f %%a in (computers.txt) do (
PsList.exe \\%%a -e "process" | Find /i "found" >nul 2>nul && (
echo %%a >> Computers_without_process.csv
)
)