Jump to content

Need help with batch file


metho

Recommended Posts

i have a problem i have 20 (or more) user accounts, i would like to change their passwords with the following command, net user account1 NEWPASSWORDi need to create a slient batch file and execute it on number of machines i.e. running one command (net user) on various accounts listed in a text file.i dont want to do the following for each account name.net user account1 NEWPASSWORDnet user account 2 NEWPASSWORDThere has to be a better way to achieve the task, i mean i want something that would scan all the accounts and if a matching account exists on a machine it would change it. i was reading about 'for' (loop) command, tried various methods without any luck. guys any sort of help would be great. thanks

Edited by metho
Link to comment
Share on other sites

Windows XP SP3
:devil: this should have worked
for /f %%A in (acct.lst) do call :process %%A:processnet user %1 | find "The user name could not be found"set LEGITUSER=%ERRORLEVEL%if {%LEGITUSER%}=={0} @echo net user %1 password

but the errorlevel returned is always 1 when run in a batch file, even though from the command line it returns 0/1 depending if found. :thumbsdown:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...