[THIN] Re: OT: service account script

  • From: "Paul DeHaan" <wppad@xxxxxxxxx>
  • To: <thin@xxxxxxxxxxxxx>
  • Date: Fri, 07 Jan 2005 11:27:41 -0500

Haven't tested this, but it look reasonable at a glance.  You'll need the 
sc.exe from the resource kit.  It might wrap and mess up the code a bit so take 
a good look.  If you can't get it, I can email it to you in a txt file.  Just 
paste the following in a batch fine and adjust as needed.

Regards,
Paul DeHaan

<<<<<<<<<<code begin>>>>>>>>>>>>>
@ECHO OFF
REM ----------------------------------------------------------------------
REM Filename: changeservice.cmd 
REM
REM Author  : Steve Seguis
REM Date    : 5/25/2000
REM Purpose : Changes the service account and password of a given service
REM           on a remote machine and adds gives that account "Log on as
REM           a service right" if required.
REM           
REM Syntax  : changeservice.cmd [computer] [service_name] [account] [password]
REM           All parameters are required. Account must be in the form
REM           DOMAIN\account
REM
REM Example : changeservice wk1 messenger DOMAIN\service servicepassword
REM
REM Notes   : You need the "real" service name and not the service name
REM           that's displayes in the services applet in the control
REM           panel to get this to work. To find out what this name is,
REM           you can use the sc.exe command to query this value.
REM 
REM
REM Requirements: 
REM           You NEED sc.exe and ntrights.exe from the NT Resource Kit 
REM           and it MUST be in your path. You MUST be an administrator
REM           on the remote machine.
REM
REM ----------------------------------------------------------------------
setlocal
if "%1"=="" goto syntax
if "%1"=="/?" goto syntax
if "%1"=="-?" goto syntax
if "%2"=="" goto syntax
if "%3"=="" goto syntax
if "%4"=="" goto syntax

set comp=%1
set service=%2
set account=%3
set password=%4

ping -n 1 %comp% | find /I "Reply"
IF NOT "%ERRORLEVEL%"=="1" goto end
GOTO BEGIN

:begin
REM === begin script if machine is up

REM === Give account logon as a service right on remote machine
REM     You can comment the next two lines out if that account already
REM     has this right on the remote machine
ECHO Adding Logon as a service rights for %account%...
ntrights.exe +r SeServiceLogonRight -u %account% -m \\%comp%

REM === Don't modify this line unless you know the exact syntax
REM     for the sc.exe command. If you do, I don't guarantee that
REM     it will work anymore
ECHO Reconfiguring Services...
sc.exe \\%comp% config %service% obj= %account% password= %password%
goto end


:syntax
ECHO.
ECHO Filename: changeservice.cmd 
ECHO.
ECHO Author  : Steve Seguis
ECHO Date    : 5/25/2000
ECHO Purpose : Changes the service account and password of a given service
ECHO           on a remote machine and adds gives that account "Log on as
ECHO           a service right" if required.
ECHO.          
ECHO Syntax  : changeservice.cmd [computer] [service_name] [account] [password]
ECHO           All parameters are required. Account must be in the form
ECHO           DOMAIN\account
ECHO.
ECHO Example : changeservice wk1 messenger DOMAIN\service servicepassword
ECHO.
ECHO Notes   : You need the "real" service name and not the service name
ECHO           that's displayes in the services applet in the control
ECHO           panel to get this to work. To find out what this name is,
ECHO           you can use the sc.exe command to query this value.
ECHO.
ECHO.
ECHO Requirements: 
ECHO           You NEED sc.exe and ntrights.exe from the NT Resource Kit 
ECHO           and it MUST be in your path. You MUST be an administrator
ECHO           on the remote machine.
ECHO.
goto end

:end
endlocal
<<<<<<<<<<<code end>>>>>>>>>>>>

>>> roger.riggins@xxxxxxxxxx 01/07/05 10:58AM >>>
We had a member of IT leave today. I changed the password on the service
account, but don't want to touch all of the severs to update the
password on each service. Does anybody have a script to do what I want?

Thanks!
R

********************************************************
This Weeks Sponsor SeamlessPlanet.com Domain Names
Register your .com domain name for as low as $7.85
One of the lowest prices on the web! Part of The Kenzig Group.
http://www.seamlessplanet.com 
**********************************************************
Useful Thin Client Computing Links are available at:
http://thin.net/links.cfm 
ThinWiki community - Awesome SBC Search Capabilities!
http://www.thinwiki.com 
***********************************************************
For Archives, to Unsubscribe, Subscribe or
set Digest or Vacation mode use the below link:
http://thin.net/citrixlist.cfm
********************************************************
This Weeks Sponsor SeamlessPlanet.com Domain Names
Register your .com domain name for as low as $7.85
One of the lowest prices on the web! Part of The Kenzig Group.
http://www.seamlessplanet.com
**********************************************************
Useful Thin Client Computing Links are available at:
http://thin.net/links.cfm
ThinWiki community - Awesome SBC Search Capabilities!
http://www.thinwiki.com
***********************************************************
For Archives, to Unsubscribe, Subscribe or
set Digest or Vacation mode use the below link:
http://thin.net/citrixlist.cfm

Other related posts: