【发布时间】:2015-06-07 17:43:07
【问题描述】:
我想让安装程序(在安装过程中)提示用户输入凭据。我实际上希望它提示用户。 我已经完成了我在此处阅读的大多数问题/答案中看到的内容,将帐户设置为用户。
我也尝试过以最低限度来做到这一点。 我创建了一个新的 Windows 服务项目。然后我创建了一个 Visual Studio 安装程序(安装项目)。
在windows服务项目中,在.cs文件(我称之为ProjectInstaller)中,右键点击主设计页面,点击添加安装程序,出现了两个安装程序。在我的 ProjectInstaller.Designer.cs 中,我在 InitializeComponent 方法中添加了这行代码
this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.User;
然后我转到我的安装程序设置项目,右键单击,将主输出设置为 Windows 服务项目,就是这样。编译所有内容并运行安装程序文件,但它没有提示我输入凭据。
我不知道它是否会有所帮助,但这是整个 InitializeComponent 方法
private void InitializeComponent()
{
this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller();
this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller();
this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.User;
//
// serviceProcessInstaller1
//
this.serviceProcessInstaller1.Password = null;
this.serviceProcessInstaller1.Username = null;
this.serviceProcessInstaller1.AfterInstall += new System.Configuration.Install.InstallEventHandler(this.serviceProcessInstaller1_AfterInstall);
//
// serviceInstaller1
//
this.serviceInstaller1.ServiceName = "Service1";
this.serviceInstaller1.AfterInstall += new System.Configuration.Install.InstallEventHandler(this.serviceInstaller1_AfterInstall);
//
// ProjectInstaller
//
this.Installers.AddRange(new System.Configuration.Install.Installer[] {
this.serviceProcessInstaller1,
this.serviceInstaller1});
}
我缺少什么以便我的安装程序提示用户输入凭据?
【问题讨论】:
标签: c# windows service installation