Hello, I am trying to output the local user accounts and their properties by using WMIC queries to get a list of Local accounts and then run the NET USE command against the account name for the properties. However, the LocalAccounts.txt with the user account names in is not been read by the FOR command.
The weird thing is if I create my own text file called LocalAccounts.txt with the same data it works. It just doesn't seem to like what is generated from the WMIC command..?
Can someone help solve?
Thanks
Tom
@ECHO OFF
WMIC PATH WIN32_USERACCOUNT WHERE LOCALACCOUNT=TRUE GET Name>"%~dp0LocalAccounts.txt"
FOR /f "usebackq delims=|" %%a IN ("%~dp0LocalAccounts.txt") DO (
CALL :USER_INFO %%a
)
IF EXIST "%~dp0LocalAccounts.txt" DEL /F "%~dp0LocalAccounts.txt"
GOTO :EOF
:USER_INFO
NET USER %1
ECHO.