So I have a script that grabs a list of users and then sets a password for all of them, simple enough right? However, When I get the list of users using the wmic output (which is converted to the corrected format using a loop) each user gets an output similar to
"Administrator "
"Guest "
"DefaultAdmin "
...
now this list needs to be used in a loop to set the passwords which is a simple for loop to set the passwords, however when you use these users in command prompt it sees them as
net user "Administrator " Password
in which case there is not such thing as administrator with 6 spaces
My question is how am I to remove the spaces after the names without manually going in to the text document?
(for /F "skip=1 delims=" %%X in ('wmic UserAccount where "LocalAccount=True" get Name') do (
for /f "delims=" %%Y in ("%%X") do (echo %%Y)
))>AllUsers.txt