c# - 静默安装 SQL Server 2008 服务包时抑制 UAC 帐户设置窗口

标签 c# sql-server-2008 batch-file windows-server-2008-r2 uac

我的 PC 上有两个帐户,一个是管理员帐户,一个是用户帐户。用户帐户具有安装新程序的管理员权限。我通常使用我的用户帐户。当我想为 SOL Server 2008 安装 SQL Server Service Pack 3 时,UAC 窗口提示我单击是或否以继续安装。

我不希望这样的事情发生。我在安装过程中不需要中断。 我怎样才能禁止该 UAC 消息框?

我正在从我的 C# 程序中调用一个 .BAT 文件。这是命令行:

start /WAIT C:\Temp\SQLSP3.exe /quiet 
      /IAcceptSQLServerLicenseTerms /Action=Patch /AllInstances

以下是UAC提示。请帮我压制这个。

UAC

这是使用管理员凭据提升 BAT 文件执行的 C# 代码。

        p.StartInfo.UseShellExecute = false;
        p.StartInfo.RedirectStandardOutput = true;
        p.StartInfo.FileName = windrive + @"temp\SQLSP3.BAT";
        p.StartInfo.Arguments = DateTime.Now.ToShortDateString().ToString().Replace('/', '-') + ".db";
        p.StartInfo.UserName = "Admin";
        SecureString adminpassword = new SecureString();
        adminpassword = ConvertToSecureString(Password);
        p.StartInfo.Password = adminpassword;
        try
        {
            p.Start();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            Console.WriteLine(ex.InnerException);
            Console.ReadLine();
        }

最佳答案

以下命令在安装 SQL SP3 包之前禁用了 UAC 提示。

C:\Windows\System32\cmd.exe /k %windir%\System32\reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f
C:\Windows\System32\cmd.exe /k %windir%\System32\reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v ConsentPromptBehaviorAdmin /t REG_DWORD /d 0 /f

关于c# - 静默安装 SQL Server 2008 服务包时抑制 UAC 帐户设置窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34104177/

相关文章:

c# - 当 CompilerParameters.GenerateInMemory == true 时,在运行时编译类失败

c# - .NET 中的验证框架,可以在字段之间进行编辑

c# - 无法解析来自根提供程序 .Net Core 2 的作用域服务

c# - 将 e.NewValue 转换为十进制

sql - 我应该如何将这些数据迁移到这些 Sql Server 表中?

sql-server - 如何获取姓名以字母A和B开头的员工数量

使用 CharIndex 错误的 SQL 替换函数

batch-file - 空闲物理内存

batch-file - 如果时间是晚上 10 点至凌晨 4 点,则批处理文件运行 cmd1,否则运行 cmd2

python - 如何从 Windows 命令提示符杀死 python?