Selectively disabling UAC for specific programs on Windows Programatically

Quick description: Make a new console/window application to run any application bypassing UAC choosing the path of your target application in this application as guided below, compile this program once, and run anytime

Step by step

  1. Download Microsoft.Win32.TaskScheduler.dll from This link => Original Source => dllme.com
  2. Make a c# application (Windows or Console) and add reference to the above dll
  3. Add New Item (Application Manifest File) to your project (this application)
  4. Change <requestedExecutionLevel level="asInvoker" uiAccess="false" />
    to <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
  5. Write following code in your program.cs file

using System;
using Microsoft.Win32.TaskScheduler;
class Program
{
   static void Main(string[] args)
   {
      TaskService ts = new TaskService();          
      TaskDefinition td = ts.NewTask();
      td.Principal.RunLevel = TaskRunLevel.Highest;
      //td.Triggers.AddNew(TaskTriggerType.Logon);          
      td.Triggers.AddNew(TaskTriggerType.Once);    // 
      string program_path = @"c:\wamp\wampmanager.exe";
      // you can have dynamic value for 'program_path'
      //even of user choice giving an interface in win-form app

      td.Actions.Add(new ExecAction(program_path, null));
      ts.RootFolder.RegisterTaskDefinition("anyNamefortask", td);          
   }
}

6.Now compile and run your Application(this app)


Now your application (e.g WAMP) will run without prompting any UAC dialog on your desired schedule (every time your log on windows in my case)

Sources

Initiated from : Can you turn off UAC for a single app? and Selectively disabling UAC for specific programs on Windows 7

Basic Idea from : Make Vista launch UAC restricted programs at startup with Task Scheduler

Basic Implementation from Creating Scheduled Tasks

Leave a Comment