M
mikhlove
Trying to get this to work, but the IF ERRORLEVEL test is not working. The errorlevel that comes back from the find command is always 0.
Thanks to anyone that can help.
@echo off
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
FOR /F %%a IN (Alluserlist.txt) do (
@net user %%a /DOMAIN > Domaindata\%%a.txt
)
FOR /R "C:\Documents and Settings\me\My Documents\DomainData" %%a in (*.txt) DO (
Echo %%a
Find /I "Account active Yes" "%%a"
rem **** WHY AM I ALWAYS GETTING ERRORLEVEL 0 HERE ****
rem **** NO MATTER IF THE ACCOUNT IS ACTIVE OR NOT ****
rem **** It works fine if it is not in a FOR LOOP, and only tests against one file ****
ECHO ERRORLEVEL = %ERRORLEVEL%
rem **** I Know the above echo will change the errorlevel, but it is there just as a test ****
rem **** Until I can get this working. ****
IF %ERRORLEVEL% EQU 0 (Echo %%a >> StillAValidUser.txt) ELSE (Echo %%a >> NoLongerAValidUser.txt)
)
pause
endlocal
Thanks to anyone that can help.
@echo off
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
FOR /F %%a IN (Alluserlist.txt) do (
@net user %%a /DOMAIN > Domaindata\%%a.txt
)
FOR /R "C:\Documents and Settings\me\My Documents\DomainData" %%a in (*.txt) DO (
Echo %%a
Find /I "Account active Yes" "%%a"
rem **** WHY AM I ALWAYS GETTING ERRORLEVEL 0 HERE ****
rem **** NO MATTER IF THE ACCOUNT IS ACTIVE OR NOT ****
rem **** It works fine if it is not in a FOR LOOP, and only tests against one file ****
ECHO ERRORLEVEL = %ERRORLEVEL%
rem **** I Know the above echo will change the errorlevel, but it is there just as a test ****
rem **** Until I can get this working. ****
IF %ERRORLEVEL% EQU 0 (Echo %%a >> StillAValidUser.txt) ELSE (Echo %%a >> NoLongerAValidUser.txt)
)
pause
endlocal