开发者

Visual Studio 2010: Windows Service Installer - How To Specifiy Service Credentials

开发者 https://www.devze.com 2023-03-19 21:05 出处:网络
I have created a Windows Service, and an associated installer using Visual Studio 2010. All of this works fine, and the Installer creates the service, and sets it\'s Log On credentials to Local System

I have created a Windows Service, and an associated installer using Visual Studio 2010. All of this works fine, and the Installer creates the service, and sets it's Log On credentials to Local System - as is specified within the ServiceInstaller code in the Project.

However, Local System is not sufficient for the applications needs. I need to allow the user to specify within the installer the appropriate Credentials to use for the Service. I don't want to have a Custom UI screen that takes the values and stores them in the registry for some post-install script to use, nor do I want to hard code the details within the Installer (as this will be used across many sites with different Accounts and Domains used for the Service).

Can anyone provide a suggestion on how to do this? I'm guessing it will involve a Custom Action DLL or something simila开发者_开发问答r.


First you will need to add a custom dialog which retrieves the service credentials. Perhaps this tutorial will help: http://www.codeproject.com/KB/install/vsSetupCustomDialogs.aspx

The installer properties associated with your service edit boxes can then be used for your service. Installer class actions don't have direct access to installer properties. So you will need to use another custom action. For example, you can launch sc.exe with a custom command line that sets your service credentials.

Finally, you will need to make sure that the Log on as a service policy is set for the specified user account. Perhaps this will help: WIX: Windows Service Repair failing on lack of permissions + how to detecting repair mode?


Just set the username and password null. It will promote a dialog for input.

0

精彩评论

暂无评论...
验证码 换一张
取 消