3

I have two account's on my PC, an admin account an user account. User account has admin privileges to install new programs. I usually work with my user account. When I want to install a SQL Server service pack 3 for SOL Server 2008, the UAC window prompts me to click yes or no to continue installation.

I don't want that to happen. I need no interruption during my installation. How can I suppress that UAC message box ?

I am calling a .BAT file from my C# program. This is the command line:

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

Following is the UAC prompt. Please help me in supressing this.

UAC

This is the C# code to elevate the BAT file execution with Admin Credentials.

        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();
        }
  • I'm not sure if this can be answered. The installation clearly requires Administrator privileges, so it needs to request them from the user. – Hexaholic Dec 05 '15 at 11:48
  • Yeah, I am calling this BAT file through C# exe , where i m Passing Admin password. But still UAC prompts user to click yes for Continuing installation. – Sudheer Muthusamy Dec 05 '15 at 12:12
  • How do you call the Batch file? I don't know C#, but maybe someone who does will have a look at the code. – Hexaholic Dec 05 '15 at 12:51
  • Run the batch file in an elevated command window. (Or it can elevate itself before doing anything else; I believe there are existing questions and answers covering how to do that.) – Harry Johnston Dec 06 '15 at 00:38
  • 1
    Possible duplicate of [Selectively disabling UAC for specific programs on Windows Programatically](http://stackoverflow.com/questions/15191129/selectively-disabling-uac-for-specific-programs-on-windows-programatically) – xmojmr Dec 06 '15 at 08:39
  • "But UAC still prompts user" - uh, well, that's exactly what's supposed to happen. You cannot bypass the UAC prompt in this way. (If you could, that's exactly what all malware would do!) – Bill_Stewart Dec 20 '15 at 16:15

2 Answers2

1

This following command has disabled the UAC Prompt before installation of SQL SP3 pack.

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
0

I posted a somewhat granular (but ugly) solution here:

http://stackoverflow.com/questions/5344021/bypass-uac-in-vbscript/34445992#34445992

Basically you need to have a task scheduler point to the install '.exe' file. The install '.exe' file would need to always have the same name and be in the same directory. My implementation fires the event from vbscript but there is no reason why you can't do it from any '.net' language. You would need to change the 'WSH' in the taskscheduler event filter to the appropriate string if you don't stick with firing the event from vbscript.

It only works if you can kick off an application from the task scheduler. I have it running on two Windows 7 laptops. It is an administrative solution. You need administrator privilege to implement it. I use it for powershell and for my UPS power backup application. I suspect I'll find other uses.