batch file - Numeric comparison CMD issue -
the if statement here not work.why? mean sid ends 502 , enters first condition 502 greater 1000. -update : seems length problem.the number of digits must equal on both sides of comparison.how force them equal length ?
@echo off echo programa de usuarios /f "skip=1" %%a in ('wmic useraccount name') ( if %%a gtr 0 ( /f "tokens=8 delims=-" %%b in ('wmic useraccount name^="%%a" sid') ( echo user accounts: if %%b geq 1000 ( echo name echo %%a wmic useraccount name^="%%a" sid echo %%b ) ) ) ) /f "skip=1" %%a in ('wmic useraccount name') ( if %%a gtr 0 ( /f "tokens=8 delims=-" %%b in ('wmic useraccount name^="%%a" sid') ( echo system accounts: if %%b lss 1000 ( echo name echo %%a wmic useraccount name^="%%a" sid echo %%b ) ) ) )
its because of string comparison. need set variable number set /a
/f "tokens=8 delims=-" %%b in ('echo s-1-5-21-2685429265-1343094091-1357998488-3175') (set /a num=%%b) if %num% lss 1000 (echo less)
Comments
Post a Comment