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

  • SEARCH
  • Home
  • 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 987503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:29:10+00:00 2026-05-16T05:29:10+00:00

I want to set the user account for Windows Service even before installing. I

  • 0

I want to set the user account for Windows Service even before installing.
I am doing it by adding code in project installer.

this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.User;
this.serviceProcessInstaller1.Password = ConfigurationSettings.AppSettings[“password”];
this.serviceProcessInstaller1.Username = ConfigurationSettings.AppSettings[“username”];

Still its prompting for Username and password. Looks like the configuration file is not getting ready by the time the installation is done.

How I can i pull the username and password from configuration file instead of hardcoding it?

  • 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-05-16T05:29:11+00:00Added an answer on May 16, 2026 at 5:29 am

    Well, I’m at a loss to say why the AppSettings values are not readable in the traditional manner while the installer is running. I tried it myself and ran into the same problem you are having. However, I was able to get around the problem by loading the configuration file as a regular XML file and reading it that way. Try this:

    XmlDocument doc = new XmlDocument();
    doc.Load(Assembly.GetExecutingAssembly().Location + ".config");
    
    XmlElement appSettings = (XmlElement)doc.DocumentElement.GetElementsByTagName("appSettings")[0];
    
    string username = null;
    string password = null;
    
    foreach (XmlElement setting in appSettings.GetElementsByTagName("add"))
    {
        string key = setting.GetAttribute("key");
        if (key == "username") username = setting.GetAttribute("value");
        if (key == "password") password = setting.GetAttribute("value");
    }
    
    serviceProcessInstaller1.Account = ServiceAccount.User;
    serviceProcessInstaller1.Username = username;
    serviceProcessInstaller1.Password = password;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Whenever a windows service is installed/reinstalled, i want to assign the set user to
I want to store the username/password information of my windows service 'logon as' user
I must be missing something. I want to set up a database user account
I want to set a cookie if user is logged in or not. My
so I made a simple user log in website, and I want to set
I have a set of radio buttons. In some cases I want the user
i want to set up a test account to test in app purchase on
I want to execute something like this: UPDATE grades SET status=pass WHERE recno=123; However,
I want set interfaceOrientation in one UIView as LandscapeLeft and Portrait in other UIView.
i want set the visibility to itemized overlay in map view. if the zoom

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.