I need to use InstallUtil to install a C# windows service. I need to set the service logon credentials (username and password). All of this needs to be done silently.
Is there are way to do something like this:
installutil.exe myservice.exe /customarg1=username /customarg2=password
A much easier way than the posts above and with no extra code in your installer is to use the following:
Just ensure the account you use is valid. If not you will receive a "No mapping between account names and security id's was done" exception
InstallUtil.exe
sets StartupType=ManualIn case you want to autostart the service, use:
sc config MyServiceName start= auto
(note there there has to be a space after '=')
You can also force your service to run as User using ServiceProcessInstaller::Account = ServiceAccount.User;
A popup asking "[domain\]user, password" will appear during service installation.
Bravo to my co-worker (Bruce Eddy). He found a way we can make this command-line call:
It is done by overriding OnBeforeInstall in the installer class:
No, installutil doesn't support that.
Of course if you wrote an installer; with a custom action then you would be able to use that as part of an MSI or via installutil.