繁体   English   中英

C#Windows Service安装程序提示用户输入凭据

[英]c# windows service installer prompt user for credentials

我想让安装程序(在安装过程中)提示用户输入凭据。 我实际上希望它提示用户。 我已经完成了我在此处阅读的大多数问题/答案中所看到的内容,将帐户设置为用户。

我还尝试了最低限度的工作。 我创建了一个新的Windows服务项目。 然后,我创建了一个Visual Studio安装程序(安装项目)。

在Windows服务项目的.cs文件(我称为ProjectInstaller)中,右键单击主设计页面,然后单击“添加安装程序”,它出现了两个安装程序。 在我的ProjectInstaller.Designer.cs中,我在InitializeComponent方法中添加了以下代码

this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.User;

然后,我进入我的Installer安装项目,右键单击,将主输出设置为Windows Service项目,仅此而已。 编译了所有内容并运行了安装程序文件,但没有提示我输入凭据。

我不知道是否有帮助,但这是整个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});

    }

我缺少什么以便安装程序提示用户输入凭据?

默认情况下,您不能这样做。 可以做的是使用新的自定义页面创建WiX设置,该页面允许用户输入服务帐户的凭据。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM