Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a WCF Service being hosted by a Windows Service.

How would I go about starting the service from the command line while passing the following arguments

The user I would like the service to logon as. I also need to pass in the password for the user.

I have previously been entering the values into services.msc but I find this tiresome

share|improve this question

2 Answers 2

up vote 6 down vote accepted

On which Windows release?

On recent ones, sc.exe is your friend here.

sc start ServiceName
sc stop ServiceName

sc config ServiceName option= value

The last one lets you set many things, amongst them the startup type and the service's logon user account (and password).

sc is odd in that, when using the config argument a space must follow each argument's equals sign.

share|improve this answer
    
You're the man. That is it. –  bearrito Jul 28 '10 at 20:24
1  
Thanks Evan, I totally forgot about the "space" thing. –  Massimo Jul 29 '10 at 5:35

Additionally, if you are always working locally (i.e. not remoting controlling services on other machines) you can use

net start "service name"
net stop "service name"

To expand on Massimo's answer, you can use service control (sc) to minipulate services on other machines in your domain:

sc \\serverName start "service name"
sc \\serverName stop "service name"
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.