Does anyone know how to get the arguments I declare in ServiceInstall to be passed to the service when it starts up? They always seem to be null in my OnStart(string[] args).
<ServiceInstall
Id="ServiceInstaller"
Type="ownProcess"
Vital="yes"
Name="MyService"
DisplayName="MyService"
Description="MyService Desc"
Start="auto"
Account="LocalSystem"
ErrorControl="ignore"
Interactive="yes"
Arguments="MY ARGS HERE"
>
</ServiceInstall>
<ServiceControl Id="ServiceControl" Start="install" Stop="both" Remove="uninstall" Name="MyService" Wait="yes" />
The best way to check if you have WiX Toolset installed is by opening up the Command Prompt and trying to execute the light.exe command. You can also check in the Programs and Features section of Control Panel.
Kind of old, but here's what you can do
<ServiceInstall
Id="SomeService"
Type="ownProcess"
Vital="yes"
Name="Some Service"
DisplayName="Some Service"
Description="Monitoring and management of some service"
Start="auto"
Account="LocalSystem"
ErrorControl="normal"
Interactive="no"/>
<ServiceControl Id="StartSomeService" Start="install" Stop="both" Remove="uninstall" Name="Some Service" Wait="yes">
<ServiceArgument>[P_USEREMAIL]</ServiceArgument>
<ServiceArgument>[P_USERPASSWORD]</ServiceArgument>
<ServiceArgument>[P_DEFAULTNAMINGCONTEXT]</ServiceArgument>
<ServiceArgument>[P_USEHTTPPROXY]</ServiceArgument>
<ServiceArgument>[P_PROXYADDRESS]</ServiceArgument>
<ServiceArgument>[P_PROXYDOMAIN]</ServiceArgument>
<ServiceArgument>[P_PROXYUSERNAME]</ServiceArgument>
<ServiceArgument>[P_PROXYPASSWORD]</ServiceArgument>
</ServiceControl>
Update: The WIX documentation is tragically unaspiring when it comes to this element.
Basically, you can set the (public) WIX variables, defined as [P_*] per usual (e.g. msiexec arguments, static, or in a CA). These values are passed to the service at startup in the same manner as if you concatenated these values in a string that you supply as start parameters when starting a service from the services console (or with net start I imagine). In my case, these were space delimited values, e.g. [P_USERMAIL] is "--useremail [email protected]", although this is arbitrary as you'll handle this in the service start code that you posted.
As you probably know, these values are not persisted. If the service fails to initialize with the values as you provided, you will need to either re-install/repair or pass them in to the service another way (i.e. services console, net start).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With