这里的if语句不起作用。为什么?我的意思是SID以502结束,它进入第一个条件,就像502大于1000. -UPDATE:所以看起来这是一个长度问题。比较两边的数字位数必须相等。我如何强迫它们长度相等?
@ECHO OFF
ECHO PROGRAMA DE USUARIOS
for /f "skip=1" %%a in ('wmic useraccount get name') do (
if %%a GTR 0 (
for /f "tokens=8 delims=-" %%b in ('wmic useraccount where name^="%%a" get sid') do (
echo User Accounts:
if %%b GEQ 1000 (
echo NAME
echo %%a
wmic useraccount where name^="%%a" get sid
echo %%b
)
)
)
)
for /f "skip=1" %%a in ('wmic useraccount get name') do (
if %%a GTR 0 (
for /f "tokens=8 delims=-" %%b in ('wmic useraccount where name^="%%a" get sid') do (
echo System Accounts:
if %%b LSS 1000 (
echo NAME
echo %%a
wmic useraccount where name^="%%a" get sid
echo %%b
)
)
)
)
答案 0 :(得分:1)
因为字符串比较。您需要使用SET / A
将变量设置为数字for /f "tokens=8 delims=-" %%b in ('echo S-1-5-21-2685429265-1343094091-1357998488-3175') do (set /A NUM=%%b) if %NUM% LSS 1000 (echo less)