【问题标题】:With a Service install msi, Is there a way to force the installer to re-prompt the user if credentials were entered incorrectly使用服务安装 msi,如果凭据输入错误,是否有办法强制安装程序重新提示用户
【发布时间】:2011-02-03 20:17:17
【问题描述】:

在安装 Windows 服务期间(使用类 MyServiceInstaller:Installer,以及 ServiceInstaller 和 ServiceProcessInstaller),如果用户输入错误,是否可以强制安装程序重新提示用户输入其用户帐户信息。

当给出不正确的信息时,安装会抛出错误 1001 消息,提示用户名或密码不正确,然后安装失败。我想重新提示用户,直到他们正确为止,或者他们取消凭据输入提示。

我可以覆盖 OnBeforeRollback,并告诉它重试吗?

    private ServiceInstaller _ServiceInstaller;
    private ServiceProcessInstaller _ProcessInstaller;

    public GBServiceInstaller()
    {
        InitializeComponent();
        _ServiceInstaller = new ServiceInstaller();
        _ProcessInstaller = new ServiceProcessInstaller();
        _ServiceInstaller.ServiceName = MyService.SERVICENAME;
        _ServiceInstaller.Description = MyService.SERVICEDESCRIPTION;
        _ServiceInstaller.StartType = ServiceStartMode.Manual;
        Installers.Add(_ServiceInstaller);
        Installers.Add(_ProcessInstaller);

【问题讨论】:

    标签: c# windows-services serviceinstall


    【解决方案1】:

    我认为当安装程序已经准备开始回滚时,可能为时已晚。相反,与其让安装程序失败,不如在安装实际服务之前测试用户名和密码是否正确。

    有多种方法可以做到这一点,一种相当简单的方法是使用here 所述的LogonUser API 函数,here 是有关如何使用 PInvoke 从 C# 调用它的信息。

    【讨论】:

      猜你喜欢
      • 2015-06-07
      • 2013-02-21
      • 1970-01-01
      • 1970-01-01
      • 2011-11-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-30
      相关资源
      最近更新 更多