Building installation package with service credentials in it

1.3k Views Asked by At

I am using wix/dotnetinstaller to install a windows service. The service will need to run under a non system account that is set up by the user. Is it possible to build installation package with credential included ? Whole idea is to preparing package when user ( after login to his web panel ) click download button. Generated package should have credential included and after installation there won't be necessary to put it again.

2

There are 2 best solutions below

0
On

I'm pretty sure you can't do that because to start a service with the user's credentials you'll need the user's password, and you can't get hold of it. Why does this process you're running need to be a service? You could create it as an ordinary process and have it in the Startup menu of the user, then it will start when the user logs on.

1
On

As you no doubt know it is not advisable to run a service with user credentials for security reasons and maintainability alike. However, if you use Windows Installer you can input the service credentials during installation or set them on the command line like this:

msiexec.exe /I "C:\Test.msi" /QN /L* "C:\Tmp\msilog.log" USERNAME="Test" PASSWORD="Test"

You then author the ServiceInstall and ServiceControl tables in the MSI file to install and configure the service using the properties USERNAME and PASSWORD for StartName and Password columns respectively.

I would recommend using WIX for this - which is a free tool capable of compiling MSI binaries from XML source files. For a crash course in WIX I recommend these two sources:

  1. Simple "get going" sample from Code Project
  2. Full blown WIX tutorial

If you are a "tinkerer" these two sources - particularly the first one - will help you get going pretty fast using WIX.

You can also use more higher level tools with better GUI and some "automagic" such as Installshield and Advanced Installer.