Change Service account User Account and Password 
Author Message
 Change Service account User Account and Password

Can WSH change an NT Service User Account and Password?

If so how?

Thanks,
Mark



Sun, 28 Oct 2001 03:00:00 GMT  
 Change Service account User Account and Password
Hi Mark

Only with WSH you cannot do this.
You need also ADSI; you can download it at Clarence Washington Jr. Site.

Once you have installad ADSI, you can use this piece of code, but i'm
not sure that it works...

dim objService

Set objService =
GetObject("WinNT://DomainName/ComputerName/ServiceName")

'stop the service if it's runnig
if objService.Status <> 1 then objService.Stop

'set username and password
objService.ServiceAccountName = "UserName"
objService.SetInfo
objService.SetPassword("UserPassword")
objService.SetInfo

'start the service
objService.Start

-Enjoy-
Legolas

Quote:

> Can WSH change an NT Service User Account and Password?

> If so how?

> Thanks,
> Mark



Mon, 29 Oct 2001 03:00:00 GMT  
 Change Service account User Account and Password

This looks close, but it did not work.

Any other ideas??


Quote:
> Hi Mark

> Only with WSH you cannot do this.
> You need also ADSI; you can download it at Clarence Washington Jr. Site.

> Once you have installad ADSI, you can use this piece of code, but i'm
> not sure that it works...

> dim objService

> Set objService =
> GetObject("WinNT://DomainName/ComputerName/ServiceName")

> 'stop the service if it's runnig
> if objService.Status <> 1 then objService.Stop

> 'set username and password
> objService.ServiceAccountName = "UserName"
> objService.SetInfo
> objService.SetPassword("UserPassword")
> objService.SetInfo

> 'start the service
> objService.Start

> -Enjoy-
> Legolas


> > Can WSH change an NT Service User Account and Password?

> > If so how?

> > Thanks,
> > Mark



Fri, 02 Nov 2001 03:00:00 GMT  
 Change Service account User Account and Password
Hi,

 I have'nt done that, but the sample looks fine.
What went wrong at your try, at which line and
which error numer?? What about your environment?
May be, all resolved now? I was missing the start
of the thread.

Best regards,
Manfred

Quote:

>This looks close, but it did not work.

>Any other ideas??



>> Hi Mark

>> Only with WSH you cannot do this.
>> You need also ADSI; you can download it at Clarence Washington Jr. Site.

>> Once you have installad ADSI, you can use this piece of code, but i'm
>> not sure that it works...

>> dim objService

>> Set objService =
>> GetObject("WinNT://DomainName/ComputerName/ServiceName")

>> 'stop the service if it's runnig
>> if objService.Status <> 1 then objService.Stop

>> 'set username and password
>> objService.ServiceAccountName = "UserName"
>> objService.SetInfo
>> objService.SetPassword("UserPassword")
>> objService.SetInfo

>> 'start the service
>> objService.Start

>> -Enjoy-
>> Legolas


>> > Can WSH change an NT Service User Account and Password?

>> > If so how?

>> > Thanks,
>> > Mark



Fri, 02 Nov 2001 03:00:00 GMT  
 Change Service account User Account and Password
There is no requirement that a service be stopped before making changes, but
you must stop/restart before the changes actually take effect (unless you're
just changing the display name).

I would try making the account change, and then do the stop/restart. That
should take care of any async issues. The ADSI 2.5 docs don't say if the
start/stop/pause/continue methods return immediately, or if they wait until
the desired status has been obtained. The return code gives a little bit of
a hint though:

                S_OK = The continue command has been successfully issued.

"Successfully issued" doesn't mean completed! It's my guess that this stuff
_is_ asynchronous.

That said, I don't see why a service in the STOP_PENDING mode would prevent
you from changing any information in the service database. None of the
documentation that I've read mentions the service database being locked at
this time.....

Oh well, your best bet is to just avoid the aync issue by doing the
stop/restart AFTER you've made changes.

Jeff

Quote:

>Have you tried a loop that waits for the service to actually stop before
>changing the service account name and password?  I assume stopping a
service
>is asynchronous since "stop pending" is a possible status
>(ADS_SERVICE_STOP_PENDING 0x00000003).

>--
>Michael Harris



Sat, 03 Nov 2001 03:00:00 GMT  
 Change Service account User Account and Password
I have not tried a loop but I have just stopped the service manually and
have tried this.

What I have found is that it is not setting the ServiceAccountName to my
variable.

Can one of you try this and tell me if it works?

Thanks for everyones help!!!
Mark Hatchett


Quote:
> Have you tried a loop that waits for the service to actually stop before
> changing the service account name and password?  I assume stopping a
service
> is asynchronous since "stop pending" is a possible status
> (ADS_SERVICE_STOP_PENDING 0x00000003).

> --
> Michael Harris



> You have not missed anything in the thread, However I am also the orginal
> post.

> I did not get any errors.  The service stops, but the account name does
not
> change, and then the service starts.

> Mark



> > Hi,

> >  I have'nt done that, but the sample looks fine.
> > What went wrong at your try, at which line and
> > which error numer?? What about your environment?
> > May be, all resolved now? I was missing the start
> > of the thread.

> > Best regards,
> > Manfred


> > >This looks close, but it did not work.

> > >Any other ideas??



> > >> Hi Mark

> > >> Only with WSH you cannot do this.
> > >> You need also ADSI; you can download it at Clarence Washington Jr.
> Site.

> > >> Once you have installad ADSI, you can use this piece of code, but i'm
> > >> not sure that it works...

> > >> dim objService

> > >> Set objService =
> > >> GetObject("WinNT://DomainName/ComputerName/ServiceName")

> > >> 'stop the service if it's runnig
> > >> if objService.Status <> 1 then objService.Stop

> > >> 'set username and password
> > >> objService.ServiceAccountName = "UserName"
> > >> objService.SetInfo
> > >> objService.SetPassword("UserPassword")
> > >> objService.SetInfo

> > >> 'start the service
> > >> objService.Start

> > >> -Enjoy-
> > >> Legolas


> > >> > Can WSH change an NT Service User Account and Password?

> > >> > If so how?

> > >> > Thanks,
> > >> > Mark



Sat, 03 Nov 2001 03:00:00 GMT  
 Change Service account User Account and Password
I've been reading more information.... Scarry thought

Anyway, do I need to do something like the following?

objService.put("????",????)

-Mark


Quote:
> I have not tried a loop but I have just stopped the service manually and
> have tried this.

> What I have found is that it is not setting the ServiceAccountName to my
> variable.

> Can one of you try this and tell me if it works?

> Thanks for everyones help!!!
> Mark Hatchett



> > Have you tried a loop that waits for the service to actually stop before
> > changing the service account name and password?  I assume stopping a
> service
> > is asynchronous since "stop pending" is a possible status
> > (ADS_SERVICE_STOP_PENDING 0x00000003).

> > --
> > Michael Harris



> > You have not missed anything in the thread, However I am also the
orginal
> > post.

> > I did not get any errors.  The service stops, but the account name does
> not
> > change, and then the service starts.

> > Mark



> > > Hi,

> > >  I have'nt done that, but the sample looks fine.
> > > What went wrong at your try, at which line and
> > > which error numer?? What about your environment?
> > > May be, all resolved now? I was missing the start
> > > of the thread.

> > > Best regards,
> > > Manfred


> > > >This looks close, but it did not work.

> > > >Any other ideas??


message

> > > >> Hi Mark

> > > >> Only with WSH you cannot do this.
> > > >> You need also ADSI; you can download it at Clarence Washington Jr.
> > Site.

> > > >> Once you have installad ADSI, you can use this piece of code, but
i'm
> > > >> not sure that it works...

> > > >> dim objService

> > > >> Set objService =
> > > >> GetObject("WinNT://DomainName/ComputerName/ServiceName")

> > > >> 'stop the service if it's runnig
> > > >> if objService.Status <> 1 then objService.Stop

> > > >> 'set username and password
> > > >> objService.ServiceAccountName = "UserName"
> > > >> objService.SetInfo
> > > >> objService.SetPassword("UserPassword")
> > > >> objService.SetInfo

> > > >> 'start the service
> > > >> objService.Start

> > > >> -Enjoy-
> > > >> Legolas


> > > >> > Can WSH change an NT Service User Account and Password?

> > > >> > If so how?

> > > >> > Thanks,
> > > >> > Mark



Sat, 03 Nov 2001 03:00:00 GMT  
 Change Service account User Account and Password
You have not missed anything in the thread, However I am also the orginal
post.

I did not get any errors.  The service stops, but the account name does not
change, and then the service starts.

Mark


Quote:
> Hi,

>  I have'nt done that, but the sample looks fine.
> What went wrong at your try, at which line and
> which error numer?? What about your environment?
> May be, all resolved now? I was missing the start
> of the thread.

> Best regards,
> Manfred


> >This looks close, but it did not work.

> >Any other ideas??



> >> Hi Mark

> >> Only with WSH you cannot do this.
> >> You need also ADSI; you can download it at Clarence Washington Jr.
Site.

> >> Once you have installad ADSI, you can use this piece of code, but i'm
> >> not sure that it works...

> >> dim objService

> >> Set objService =
> >> GetObject("WinNT://DomainName/ComputerName/ServiceName")

> >> 'stop the service if it's runnig
> >> if objService.Status <> 1 then objService.Stop

> >> 'set username and password
> >> objService.ServiceAccountName = "UserName"
> >> objService.SetInfo
> >> objService.SetPassword("UserPassword")
> >> objService.SetInfo

> >> 'start the service
> >> objService.Start

> >> -Enjoy-
> >> Legolas


> >> > Can WSH change an NT Service User Account and Password?

> >> > If so how?

> >> > Thanks,
> >> > Mark



Sat, 03 Nov 2001 03:00:00 GMT  
 Change Service account User Account and Password
Have you tried a loop that waits for the service to actually stop before
changing the service account name and password?  I assume stopping a service
is asynchronous since "stop pending" is a possible status
(ADS_SERVICE_STOP_PENDING 0x00000003).

--
Michael Harris


You have not missed anything in the thread, However I am also the orginal
post.

I did not get any errors.  The service stops, but the account name does not
change, and then the service starts.

Mark


Quote:
> Hi,

>  I have'nt done that, but the sample looks fine.
> What went wrong at your try, at which line and
> which error numer?? What about your environment?
> May be, all resolved now? I was missing the start
> of the thread.

> Best regards,
> Manfred


> >This looks close, but it did not work.

> >Any other ideas??



> >> Hi Mark

> >> Only with WSH you cannot do this.
> >> You need also ADSI; you can download it at Clarence Washington Jr.
Site.

> >> Once you have installad ADSI, you can use this piece of code, but i'm
> >> not sure that it works...

> >> dim objService

> >> Set objService =
> >> GetObject("WinNT://DomainName/ComputerName/ServiceName")

> >> 'stop the service if it's runnig
> >> if objService.Status <> 1 then objService.Stop

> >> 'set username and password
> >> objService.ServiceAccountName = "UserName"
> >> objService.SetInfo
> >> objService.SetPassword("UserPassword")
> >> objService.SetInfo

> >> 'start the service
> >> objService.Start

> >> -Enjoy-
> >> Legolas


> >> > Can WSH change an NT Service User Account and Password?

> >> > If so how?

> >> > Thanks,
> >> > Mark



Sat, 03 Nov 2001 03:00:00 GMT  
 Change Service account User Account and Password

Quote:

> This looks close, but it did not work.

> Any other ideas??

I think it only works on windows 2000

-Arthur.

Quote:



> > Hi Mark

> > Only with WSH you cannot do this.
> > You need also ADSI; you can download it at Clarence Washington Jr. Site.

> > Once you have installad ADSI, you can use this piece of code, but i'm
> > not sure that it works...

> > dim objService

> > Set objService =
> > GetObject("WinNT://DomainName/ComputerName/ServiceName")

> > 'stop the service if it's runnig
> > if objService.Status <> 1 then objService.Stop

> > 'set username and password
> > objService.ServiceAccountName = "UserName"
> > objService.SetInfo
> > objService.SetPassword("UserPassword")
> > objService.SetInfo

> > 'start the service
> > objService.Start

> > -Enjoy-
> > Legolas


> > > Can WSH change an NT Service User Account and Password?

> > > If so how?

> > > Thanks,
> > > Mark

--
*************************************************
*      You can send me email at:                *

*************************************************


Mon, 03 Dec 2001 03:00:00 GMT  
 Change Service account User Account and Password
It does not work on NT 4.0.....trust me!

Quote:

>> This looks close, but it did not work.

>> Any other ideas??

>I think it only works on windows 2000

>-Arthur.



>> > Hi Mark

>> > Only with WSH you cannot do this.
>> > You need also ADSI; you can download it at Clarence Washington Jr.
Site.

>> > Once you have installad ADSI, you can use this piece of code, but i'm
>> > not sure that it works...

>> > dim objService

>> > Set objService =
>> > GetObject("WinNT://DomainName/ComputerName/ServiceName")

>> > 'stop the service if it's runnig
>> > if objService.Status <> 1 then objService.Stop

>> > 'set username and password
>> > objService.ServiceAccountName = "UserName"
>> > objService.SetInfo
>> > objService.SetPassword("UserPassword")
>> > objService.SetInfo

>> > 'start the service
>> > objService.Start

>> > -Enjoy-
>> > Legolas


>> > > Can WSH change an NT Service User Account and Password?

>> > > If so how?

>> > > Thanks,
>> > > Mark

>--
>*************************************************
>*      You can send me email at:                *

>*************************************************



Tue, 04 Dec 2001 03:00:00 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. change account/password for service startup

2. Changing service account password on all servers remotely

3. Changing service account password on all servers remotely

4. Changing service account password on all servers remotely

5. automatic create user account, computer account in 2000 server

6. Help with creating list of User accounts and then determining Account status

7. Changing Service Account w/ADSI

8. vbscript to change Service Account Informaton

9. Changing Local account password

10. exporting user account password expiry status

11. Change Account That Service Runs Under

12. ADSI: Change service account info question

 

 
Powered by phpBB® Forum Software