views:

355

answers:

5

I have created a windows service that has the Account set to user. Which means that when I install the service I need to pass a user name and password. Is there a way to set these maybe in the ProjectInstaller class maybe in the BeforeInstall event? if so HOW?

A: 

I have a suggestion for that here.

Magnus Johansson
A: 

Take a look at DynamicInstaller from CodeProject

Shay Erlichmen
A: 

Take a look at System.ServiceProcess.ServiceProcessInstaller

MattH
A: 

There is a bit about setting service parameters and stuff in A Windows Service without a template Its on page 5 in the bit about customising a service.

mikej
A: 

Normally you will be able to pass those credentials to the Installer class. You can either hard-code it or pass it as a command-line argument. The second approach is more appropriate but it will require you to parse the command-line arguments unnecessarily.

I propose to you a third approach...

<ShamelessPlug>

Hi! I am a developer for an open source windows service hosting framework called Daemoniq. And passing credentials via command-line is one of its features. You can download it from http://daemoniq.org

Current features include:

  • container agnostic service location via the CommonServiceLocator
  • set common service properties like serviceName, displayName, description and serviceStartMode via app.config
  • run multiple windows services on the same process
  • set recovery options via app.config
  • set services depended on via app.config
  • set service process credentials via command-line
  • install, uninstall, debug services via command-line

</ShamelessPlug>

Cheers!

jake.stateresa