如何允许在不提示用户ID、密码和确认密码的情况下安装服务

本文关键字:密码 确认 情况下 服务 安装 何允许 提示 ID 用户 | 更新日期: 2023-09-27 18:29:04

当我尝试从Visual Studio命令提示符安装服务(installutil service.exe)时,它会提示设置用户ID和密码以安装该服务。您可以参考凭证提示的屏幕截图(链接)。

安装服务时提示输入凭据的图片。

这是在带有.net 4.0框架的C#中完成的。

我已经搜索了这个之前发布的问题,最终将凭据设置为空(请参阅下面粘贴的代码)。但它没有起作用。

private void InitializeComponent()
    {
        this.StockManagementProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller();
        this.StockManagementInstaller1 = new System.ServiceProcess.ServiceInstaller();
        // 
        // StockManagementProcessInstaller1
        // 
        this.StockManagementProcessInstaller1.Password = null;
        this.StockManagementProcessInstaller1.Username = null;
        // 
        // StockManagementInstaller1
        // 
        this.StockManagementInstaller1.DisplayName = "StockManagement";
        this.StockManagementInstaller1.ServiceName = "StockManagement";
        this.StockManagementInstaller1.StartType = System.ServiceProcess.ServiceStartMode.Automatic;
        // 
        // ProjectInstaller
        // 
        this.Installers.AddRange(new System.Configuration.Install.Installer[] {
        this.StockManagementProcessInstaller1,
        this.StockManagementInstaller1});
    }

有人能帮我解决这个问题并安装服务吗?

如何允许在不提示用户ID、密码和确认密码的情况下安装服务

将您的服务作为本地服务安装,无需密码提示,只需执行以下操作:

// StockManagementProcessInstaller1
// 
this.StockManagementProcessInstaller1.Account = ServiceAccount.LocalService;
this.StockManagementProcessInstaller1.Password = null;
this.StockManagementProcessInstaller1.Username = null;

代替:

// StockManagementProcessInstaller1
// 
this.StockManagementProcessInstaller1.Password = null;
this.StockManagementProcessInstaller1.Username = null;

我希望这能支持你的问题。