locked
Installing a Windows Service with a user of my choosing (not Local Service). RRS feed

  • Question

  • I created a deployment MSI that installs a Windows Service. The install defaults to the user "Local Service." I would like to install so the Service uses a domain account. I also don't want the password visible. I don't want it sitting in a config file even in the project.

    Can anyone point me to an article or help me out? Point me in the right direction?

    Many thanks.

    -Scott

    Friday, June 1, 2012 10:07 PM

Answers

  • Say you have a service installer added to your service project, then override ServiceInstaller.Install which gets the data passed to the custom action in a dictionary to set any service configuration. Of cause, to get the data into the dictionary, you need to bind your controls to installer properties in the dialog editor first, then pass install properties to the custom action after the installation is complete.

    You probably want to update the control table to mask the password input. If you want to do it automatically as a post-build setup, then you need MSI database functions.



    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP



    Monday, June 4, 2012 7:20 PM
  • I think you need to allow the user to specify a domain password via some UI (e.g. something like a textbox dialog if you are using Visual Studio Setup Project).  Then you can pass the textbox values to properties and access those properties in a custom action. It would be a big security risk if you can specify the password at compile time. 


    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP

    Saturday, June 2, 2012 8:54 AM

All replies

  • I think you need to allow the user to specify a domain password via some UI (e.g. something like a textbox dialog if you are using Visual Studio Setup Project).  Then you can pass the textbox values to properties and access those properties in a custom action. It would be a big security risk if you can specify the password at compile time. 


    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP

    Saturday, June 2, 2012 8:54 AM
  • >>> Then you can pass the textbox values to properties and access those properties in a custom action.

    Would you please elaborate on this? I like the idea of the dialog box coming up. However it is how to do the above that I'm interested in. How do you set the username and password via a custom action?

    Thank you,

    Scott

    Monday, June 4, 2012 4:15 PM
  • Say you have a service installer added to your service project, then override ServiceInstaller.Install which gets the data passed to the custom action in a dictionary to set any service configuration. Of cause, to get the data into the dictionary, you need to bind your controls to installer properties in the dialog editor first, then pass install properties to the custom action after the installation is complete.

    You probably want to update the control table to mask the password input. If you want to do it automatically as a post-build setup, then you need MSI database functions.



    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP



    Monday, June 4, 2012 7:20 PM
  • If you're using Windows Installer, some tools give you IDE support to the Windows Installer functionality to install services. Some tools (notably Visual Studio setups) don't do this but most do. Ultimately, these tools populate the ServiceInstall table in the MSI file:

    http://msdn.microsoft.com/en-us/library/windows/desktop/aa371637(v=vs.85).aspx

    where StartName and Password are collected from an installer dialog.


    Phil Wilson

    Friday, June 8, 2012 7:09 PM