简体   繁体   English

如何在Windows Service安装程序中为多个实例设置启动参数和不同的凭据?

[英]How to set start parameters and different credentials for multiple instance in windows service installer?

I write a windows service and a installer project using C# with Visual Studio 2010. 我在Visual Studio 2010中使用C#编写了Windows服务和安装程序项目。

This service will get some data from database. 该服务将从数据库中获取一些数据。

There're more than one database with different windows domain login account. 有多个具有不同Windows域登录帐户的数据库。

I want the installer pass the connection string as a parameters to each service instance , each instance has different service name. 我希望安装程序将连接字符串作为参数传递给每个服务实例 ,每个实例具有不同的服务名称。

I look into MSDN and see OnStart(string[] args) . 我调查了MSDN并看到了OnStart(string[] args) It needs to write register keys to make a service run with parameters automatically. 它需要写寄存器密钥以使服务自动运行并带有参数。 Is there any other easy ways to do that? 还有其他简便的方法吗?

Beside, I set username and password value to null in my installer project. 此外,我在安装程序项目中将用户名和密码值设置为null。 A dialog will be promoted during the installation. 在安装过程中将弹出一个对话框。 But it's only once. 但是只有一次。 I want to set different credentials for each service instance. 我想为每个服务实例设置不同的凭据。 So it needs to be promotes many times. 因此需要多次推广。

Thank you. 谢谢。

Rather install as many instances as you require and use the connectionStrings section in your config file. 而是根据需要安装尽可能多的实例,并在配置文件中使用connectionStrings部分。

I have a generic host (see: http://shuttle.codeplex.com/SourceControl/changeset/view/ba9750ca1f7a#Shuttle.Core%2fsource%2fShuttle.Core.Host%2fHost.cs ) that allows you to easily implement multiple instances of services or run your code as a console application. 我有一个通用主机(请参阅: http : //shuttle.codeplex.com/SourceControl/changeset/view/ba9750ca1f7a#Shuttle.Core%2fsource%2fShuttle.Core.Host%2fHost.cs ),您可以轻松实现多个实例服务或将代码作为控制台应用程序运行。

HTH 高温超导

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Windows服务安装程序中设置“与桌面交互” - How to set “interact with desktop” in windows service installer Windows服务安装程序,无需输入凭据 - Installer for windows service without asking for credentials 使用不同的凭据从 Windows 服务启动 exe - Start exe from Windows Service using different credentials 将参数发送到Windows Service Installer Visual Studio - Send parameters to Windows Service Installer Visual Studio C#Windows Service安装程序提示用户输入凭据 - c# windows service installer prompt user for credentials 如何设置Windows服务登录凭据? - How do I set the a windows service log on credentials? 如何在C#中使用ServiceController启动Windows Service的新实例 - How to start a new instance of Windows Service using ServiceController in C# 如何将Windows服务中的参数从安装程序传递到Program.cs中的Main函数? - How to pass parameters in windows service from Installer to Main function in Program.cs? 基于 Wix 安装程序的 TopShelf Windows 服务无法启动 - Wix installer based TopShelf windows service fails to start 一个程序集中的多个服务。 安装程序如何知道要安装和启动哪个服务? - Multiple services in one assembly. How installer knows which service to install and start?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM