2

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

2 Answers 2

6

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.

1
  • You're the man. That is it.
    – bearrito
    Jul 28, 2010 at 20:24
2

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"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .