1.

Solve : Batch File - Combination of WMIC and NET USE to gather Local User Properties?

Answer»

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

Code: [Select]@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.
try this

Code: [Select]for /F .... ( 'WMIC PATH WIN32_USERACCOUNT WHERE LOCALACCOUNT=TRUE get /all /format:csv' ) do (
...
)

use delims as ","This can be called 'string substitution'. Of course you can do that in Notepad, but not from the command line. SED runs from a command and can be inside batch file. When done, SED goes BACK to the batch file.



Discussion

No Comment Found