Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8391015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:08:54+00:00 2026-06-09T19:08:54+00:00

I want to deploy a single exe which provides a web service, and be

  • 0

I want to deploy a single exe which provides a web service, and be able to start it multiple times (each as a separate Windows service). Each instance of the exe needs to be able to load a different configuration file (e.g. so it can listen on a different port, or use a different database).

Ideally, I don’t want to have to install the exe in multiple folders, just have multiple configuration files.

However there doesn’t seem to be a way of finding which service name Windows is starting.

I have looked at
How can a Windows Service determine its ServiceName?
but it doesn’t seem to work for me, because during startup the process id for the service being started is 0.

I guess I am asking too soon or something. My code does the following:

Main sets the current directory and constructs a WebService object (a subclass of ServiceBase)

The WebService object constructor now needs to set its ServiceName property, and uses the code in How can a Windows Service determine its ServiceName? to try to find the correct name. However, at this point the processid of the correct servicename is still 0.

Following this, Main will build an array of (1) ServiceBase containing the WebService object, and call ServiceBase.Run on the array. The service name needs to be correct by this point, because it may not be changed once the service is running.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T19:08:55+00:00Added an answer on June 9, 2026 at 7:08 pm

    I found an alternative way to achieve my goal, after reading https://stackoverflow.com/a/7981644/862344

    During the install of the webservice, the install program (which happens to be the same program, but with a command-line parameter of “install”) knows which settings file to use (because there is a command-line parameter “settings=”).

    The linked question shows there is a simple way to get that command-line parameter passed to the service every time it starts, by overriding the OnBeforeInstall (and OnBeforeUninstall) methods of the Installer class.

    protected override void OnBeforeInstall(System.Collections.IDictionary savedState) {
        if (HasCommandParameter("settings")) {
            // NB: Framework will surround this value with quotes when storing in registry
            Context.Parameters["assemblypath"] += "\" \"settings=" + CommandParameter("settings");
        }
        base.OnBeforeInstall(savedState);
    }
    
    protected override void OnBeforeUninstall(System.Collections.IDictionary savedState) {
        if (HasCommandParameter("settings")) {
            // NB: Framework will surround this value with quotes when storing in registry
            Context.Parameters["assemblypath"] += "\" \"settings=" + CommandParameter("settings");
        }
        base.OnBeforeUninstall(savedState);
    }
    

    I have found that something in the framework surrounds the Context.Parameters[“assemblypath”] value with quotes before storing it in the registry (at HKLM\System\CurrentControlSet\Services\\ImagePath), so it is necessary to add ‘” “‘ between the existing value (which is the exe path) and the parameter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to deploy same web application to multiple sites with different domains and
I have a class with dependencies which I want to hot deploy without restarting
I have created an iPhone application which I want to deploy onto an iPhone.
I want to use global HTTP filters. Therefor, I edited deploy/jboss-web.deployer/conf/web.xml and added: <filter>
I want to be able to deploy a new version of my asp.net/mvc website
I want to deploy to all four processes on a Websphere cluster with two
I want to deploy 2 Symfony2 projects onto an EC2 server. In addition I
I want to deploy the sencha touch application to native Android (apk) but when
I want to deploy my Jax-WS2.2 based application on CloudFoundry tomcat instance. In my
I want to deploy a firebird installation, and thus will launch it from my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.