选择禁用UAC在Windows编程方式的具体方案 [英] Selectively disabling UAC for specific programs on Windows Programatically

查看:180
本文介绍了选择禁用UAC在Windows编程方式的具体方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有几十个职位的问题/解答堆栈和有关禁用/旁路/ SUP pressing UAC其他论坛。有解决方案,以及。但progmatically也许不是。我只能看到一个解决方案禁用UAC编程但或许有给有不是真正的编程解决方案。

才能有保存用户程序上的解决方案,以提示每次他/她运行的程序像WAMP,他们总是必须点击是的,所以这将是更好地告诉窗口,他们的选择永远是肯定的。我相信会有如

我已经找到<一个href=\"http://www.techrepublic.com/blog/window-on-windows/make-vista-launch-uac-restricted-programs-at-startup-with-task-scheduler/616\"相对=nofollow> 这里 的Windows图形用户界面,通过提供任务调度这种设施,因此必须通过code是可能的。

更新:我有prepared这是工作的一个纯粹的编程解决方案。见我的答案。


解决方案

  1. 下载Microsoft.Win32.TaskScheduler.dll这codePLEX链接

  2. 请C#应用程序(Windows或控制台),并添加引用上面的dll

  3. 添加新项(应用程序清单文件)到项目(此应用程序)

  4. 更改&LT; requestedExecutionLevel水平=asInvokeruiAccess =FALSE/&GT;
    &LT; requestedExecutionLevel水平=requireAdministratoruiAccess =FALSE/&GT;

  5. 写以下在你的Program.cs文件code


 使用系统;
使用Microsoft.Win32.TaskScheduler;
类节目
{
   静态无效的主要(字串[] args)
   {
      TaskService TS =新TaskService();
      TaskDefinition TD = ts.NewTask();
      td.Principal.RunLevel = TaskRunLevel.Highest;
      //td.Triggers.AddNew(TaskTriggerType.YourDesiredSchedule);
      td.Triggers.AddNew(TaskTriggerType.Logon);
      //td.Actions.Add(new ExecAction(路径的应用程序文件,NULL));
      td.Actions.Add(新ExecAction(@C:\\ WAMP \\ wampmanager.exe,NULL));
      ts.RootFolder.RegisterTaskDefinition(anyNamefortask,TD);
   }
}

6.Now编译和运行应用程序(这个程序)


现在您的应用程序(例如WAMP)将不会(对我来说,每次在Windows日志)在您的预期时间表任何提示对话框UAC运行

来源

从启动:您可以关闭UAC为单应用?和<一个href=\"http://superuser.com/questions/99286/selectively-disabling-uac-for-specific-programs-on-windows-7\">Selectively禁用UAC在Windows 7

具体方案从

基本思想是:<一href=\"http://www.techrepublic.com/blog/window-on-windows/make-vista-launch-uac-restricted-programs-at-startup-with-task-scheduler/616\">Make Vista启动UAC限制在启动程序与任务计划程序

这是基本实现 创建计划任务

There are dozens of posts questions/answers on stack and other forums about disabling/bypassing/suppressing UAC. There are solutions as well. But progmatically perhaps not. I could see only one solution Disabling UAC programmatically but perhaps there is not real programmatic solution given there.

Can there be a programatic solution for saving user to be prompted everytime he/she runs a program like wamp and they always have to click yes, So it would be better to tell windows that their choice is always yes. I am sure there would be as

I have found Here that windows provides this facility in Task Scheduler through GUI so it must be possible through code as well.

Update : I have prepared a pure programmatic solution which is working. See my answer.

解决方案

  1. Download Microsoft.Win32.TaskScheduler.dll from This Codeplex link
  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.YourDesiredSchedule);
      td.Triggers.AddNew(TaskTriggerType.Logon);    
      //td.Actions.Add(new ExecAction("Path Of your Application File", null));
      td.Actions.Add(new ExecAction(@"c:\wamp\wampmanager.exe", 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

这篇关于选择禁用UAC在Windows编程方式的具体方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆