batch file - Change password for all users accounts in command prompt -


alright, need of batch scripting guru me out of corner i've backed myself into.

i have program runs system , want change password accounts appear in output net user. i'm not sure how command line or ahk-based scripting.

when perform net user command output me:

c:\users\resident>net user  user accounts \\9100baseline  ------------------------------------------------------------------------------- administrator            guest                    resident command completed successfully. 

i need way change password on accounts here (be 3 or 50) of choosing.

can me out this? tried slapping loop each item token before realized don't know how regex usernames out of there.

i'd recommend employing of little vbscript:

set accounts = getobject("winnt://.") accounts.filter = array("user") each user in accounts   wscript.echo user.name next 

save listusers.vbs , run this:

@echo off  setlocal  set /p "newpw=enter new password: "  /f "delims=" %%u in ('cscript //nologo c:\path\to\listusers.vbs') (   net user "%%u" "%newpw%" ) 

edit: if want omit specific accounts being processed can either add exclude list vbscript:

set exclude = createobject("scripting.dictionary") exclude.comparemode = vbtextcompare exclude.add "homegroupuser$", true exclude.add "otheruser", true ...  set accounts = getobject("winnt://.") accounts.filter = array("user") each user in accounts   if not exclude.exists(user.name) wscript.echo user.name next 

or filter output of listusers.vbs findstr:

for /f "delims=" %%u in (   'cscript //nologo c:\path\to\listusers.vbs ^| findstr /v /i ^     /c:homegroupuser$ /c:otheruser ...' ) (   net user "%%u" "%newpw%" ) 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -