One thing i am struggling with is registering a service with a user name and password.
i can hard code the user name and password to the RunAs method and register the service but obviously not practical.
if i
myservice.exe install start -username:Domain\username -password:itsAsecret
or
myservice.exe install start -username "Domain\username" -password "itsAsecret"
the service registers and starts running under the the local system.
how do i pass the username and password to the:
configure.RunAs(username, password)
method?
to get around this i have parsed the commanline my self and then i can :
if (commandlineParameters.ContainsKey("username") && commandlineParameters.ContainsKey("password"))
configure.RunAs(commandlineParameters["username"], commandlineParameters["password"]);
else
configure.RunAsLocalSystem();
but i feel this should work:
configure.ApplyCommandLine(string.Join(" ", args));
or simply
configure.ApplyCommandLine();
But when i do the service is registered as Local system
Seems the problem was the command "start" with the installation.
so, to install and start the service it will need to be two separate commands.
myservice.exe install -username:Domain\username -password:itsAsecret
myservice.exe start
This means i can get rid of the parsing code i added and simply
configure.ApplyCommandLine();