Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / March 2006

Tip: Looking for answers? Try searching our database.

System.Configuration.Install.Installer and console

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
PIEBALD - 22 Mar 2006 17:05 GMT
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.
Dmytro Lapshyn [MVP] - 23 Mar 2006 12:06 GMT
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.

>I have a Windows service exe that derives from
> System.Configuration.Install.Installer
[quoted text clipped - 14 lines]
> run from the command line while still behaving properly when running as a
> service.
PIEBALD - 23 Mar 2006 16:19 GMT
> 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

That seems a bit kludgy and I don't see where to do it anyway.

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.
PIEBALD - 23 Mar 2006 16:33 GMT
I got it...

System.Environment.UserInteractive

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.