|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
System.Configuration.Install.Installer and consoleI have a Windows service exe that derives from
System.Configuration.Install.Installer The exe can be executed from the command line with parameters such as INSTALL, UNINSTALL, START, and STOP to perform such tasks on the service But the exe is also the exe that _is_ the service process, so when it's run with no parameters (by the SCM?) it calls System.ServiceProcess.ServiceBase.Run ( srp.ServicesToRun ) ; The problem then is when it's accidently run with no parameters from the command line. Is there some way for it to know whether or not it's being executed by the SCM? I'd like it to be able to give a help message and terminate when it's run from the command line while still behaving properly when running as a service. You can analyze the command line arguments at startup, and configure the
service entry in the SCM that it runs your exe with a specific argument, say "-service". If no command-line args are supplied, don't run System.ServiceProcess.ServiceBase.Run, but display a help message instead. Show quote "PIEBALD" <PIEB***@discussions.microsoft.com> wrote in message news:8185E0B7-2741-40B4-BB2C-B7666A5A5407@microsoft.com... >I have a Windows service exe that derives from > System.Configuration.Install.Installer > > The exe can be executed from the command line with parameters such as > INSTALL, UNINSTALL, START, and STOP to perform such tasks on the service > > But the exe is also the exe that _is_ the service process, so when it's > run > with no parameters (by the SCM?) it calls > System.ServiceProcess.ServiceBase.Run ( srp.ServicesToRun ) ; > > The problem then is when it's accidently run with no parameters from the > command line. > > Is there some way for it to know whether or not it's being executed by the > SCM? I'd like it to be able to give a help message and terminate when it's > run from the command line while still behaving properly when running as a > service. > You can analyze the command line arguments at startup, and configure the That seems a bit kludgy and I don't see where to do it anyway.> service entry in the SCM that it runs your exe with a specific argument, say > "-service". If no command-line args are supplied, don't run I've looked through the properties and methods for: System.Configuration.Install.Installer System.ServiceProcess.ServiceProcessInstaller System.ServiceProcess.ServiceInstaller System.ServiceProcess.ServiceBase and not seen anything like a place to put parameters. Nor any way for INSTALLUTIL to pass them.
Other interesting topics
|
|||||||||||||||||||||||