Skip navigation

JSI Tip 0691 - How do I reset the password on all services in my domain that run in the ServiceAccount context?

If you have services that run in a DomainName/UserName context on multiple machines in your domain, resetting the DomainName/UserName password can be quite a chore.

To totally automate this process using NETSVC and SC from Supplement 4 of the Resource kit, add the following batch files to your path:


@echo off
@echo SetSvcPw %1 %2 %3
if exist %1 goto OK
@echo Syntax: Error: SetSvcPw "<Drive:>\<Path>\ComputerName.txt" DomainName\UserName password
goto end
if .%2.

.. goto bad
if .%3.

.. goto bad
for /f %%i in ('type %1') do call :setsvcpws %%i %2 %3
goto end
if exist %temp%\NETSVC.LOG del /f /q %temp%\NETSVC.LOG
for /f "Tokens=1,2* Delims=," %%a in ('netsvc \\%1 /list') do echo %%b >> %TEMP%\netsvc.log
for /f %%s in (%TEMP%\netsvc.log) do call SetSvcPwT %%s %1 %2 %3
if exist %temp%\NETSVC.LOG del /f /q %temp%\NETSVC.LOG


@echo off
if "%1"

"ECHO" goto end
for /f "Tokens=1,2,3* Delims= " %%i in ('sc \\%2 qc %1') do call :user %%k %1 %2 %3 %4
goto end
if /i NOT "%1"

"%4" goto end
echo \\%3 %2 %4 %5
sc \\%3 stop %2
sleep 4
sc \\%3 config %2 obj= %4 password= %5
sc \\%3 qc %2
sc \\%3 start %2

To run the job and log the results, type:

SetSvcPw "<Drive:>\<Path>\ComputerName.txt" DomainName\UserName password >> "<Drive:>\<Folder>\SetSvcPw.log" 2>&1

Where "<Drive:>\<Path>\ComputerName.txt" contains a list of computer names in your domain (see tip 677).
The Format of "<Drive:>\<Path>\ComputerName.txt" is:

. . . . . . . . . . . .

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.