Install windows service from command line

  • Thread starter Thread starter Brecht Yperman
  • Start date Start date
B

Brecht Yperman

Hi,

I'm trying to create an application that's, in normal use, nothing but a
simple console application (a server), but can install a service if certain
arguments are passed through.
(compare with, for instance, mysqld and mysqld --install).

Is this possible using .net?

Thanks,
Brecht
 
Hi,

Sure it is, take a look at installutil.exe from the Framework SDK as an
example. Also, please refer to MSDN docs on the ServiceInstaller class for
more detailed info.
 
Ok, thanks,

but suppose I want to add some switches,
genre mysqld --install -autostart false -user joe -pass bar

How can I retrieve them in the installer?
As I see it now upon "--install" i'd have to call installuser using the
assembly holding the ProjectInstaller (which has a ServiceInstaller and a
ServiceProcessInstaller).
How do I get the arguments there?

Thanks,
Brecht

Dmytro Lapshyn said:
Hi,

Sure it is, take a look at installutil.exe from the Framework SDK as an
example. Also, please refer to MSDN docs on the ServiceInstaller class for
more detailed info.

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]


Brecht Yperman said:
Hi,

I'm trying to create an application that's, in normal use, nothing but a
simple console application (a server), but can install a service if
certain arguments are passed through.
(compare with, for instance, mysqld and mysqld --install).

Is this possible using .net?

Thanks,
Brecht
 
Back
Top