Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

change the user that a service runs as from the CL 2

Status
Not open for further replies.

nychris

MIS
Dec 4, 2004
103
US
I'm looking for a way, from the command line, to change the user that a service runs as. I'm writing a script and part of that script needs to change the user that a service runs as, and then start it up with the net command. The script will be perl (since I'm a Unix SA helping out with a Windows issue), but any code will work.

Thanks
 
Correction to my post. It looks like the service account parameter is about the only thing that sc.exe DOESN'T support. My apologies. I've used it for just about everything else and assumed it would support your need.

Pat Richard, MCSE MCSA:Messaging CNA
Microsoft Exchange MVP
Want to know how email works? Read for yourself -
 
I did look into sc.exe from the resource kit and it doesn't seem like it will do that?? Here's the documentation on it:


I did a search on CPAN and the Win32-Daemon-Simple module might be able to do it though, I just need to figure out how to use the module and test it.


Please let me know if anyone has ever done this before.
 
tfg13, that perl code looks good. I tested it and it works, thanks dude!

Chris
 
Glad I could help. Looks like the site has a bunch of other cool perl scripts too!
 
Oh, as a side note, Pat, wouldn't WMIC be able to do the service account change?
 
Probably. I'm a big user of sc for remotely controlling things. Just like using sysinfo to look at things.

Pat Richard, MCSE MCSA:Messaging CNA
Microsoft Exchange MVP
Want to know how email works? Read for yourself -
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top