2015-10-26 47 views
-1

我正在开发需要管理权限(WMI调用,注册表访问等)的公司的iventory软件。为了方便起见,我不希望UAC提示用户执行该应用程序(是的,即使用户不需要,我也必须强制应用程序运行),并且我无法通过GPO禁用UAC(将是完美的,但屁股疼痛)。我首先尝试使用另一个进程(C#上的Processinfo)将AD管理帐户凭据传递给清单软件,但UAC提示仍然存在。经过几次研究,我发现如果使用本地管理员凭证,它不会给我任何恼人的提示,但由于我公司的环境很混乱,除了标准化之外,还有许多站点具有不同的凭据。有没有人有任何想法我可以做到这一点? (使用.net C#)。使用C调用另一个进程时避免UAC提示

+1

改为使用服务或计划任务。 –

+2

想象一下,您找到了绕过UAC的方法。现在推断所有病毒/恶意软件编写者都在不断地瞄准windows。这不是您的不便之处,它保护用户。 –

+2

“是的,我必须强制应用程序运行,即使用户不想要” - 我的意思是,这是UAC存在的全部原因。 – Rob

回答

1

我已经完成了这个使用Task Scheduler Managed Wrapper。确保您在设置任务时提供本地管理员组凭据。我的代码如下:

 using (TaskService ts = new TaskService()) 
     { 
      try 
      { 
       //Create a new task definition and assign properties 
       TaskDefinition td = ts.NewTask(); 
       td.Principal.RunLevel = TaskRunLevel.Highest; 
       td.RegistrationInfo.Description = "Paulos Task"; 
       td.Triggers.Add(new TimeTrigger() { StartBoundary = Convert.ToDateTime("01-01-2003 00:00:01") }); 

       // Create an action that will launch PauloApp whenever the trigger fires 
       td.Actions.Add(new ExecAction("PauloApp.exe", "", Environment.ExpandEnvironmentVariables(@"%ProgramFiles%\Paulo"))); 

       td.Settings.DisallowStartIfOnBatteries = false; 
       td.Settings.StopIfGoingOnBatteries = false; 

       ts.RootFolder.RegisterTaskDefinition("PaulosTask", td, 
        TaskCreation.CreateOrUpdate, "Administrators", null, 
        TaskLogonType.Group); 

       // Register the task in the root folder 
       Microsoft.Win32.TaskScheduler.Task t = ts.FindTask("PaulosTask"); 
       if (t != null) 
        t.Run(); 
       else 
        //could not find PaulosTask 
      }//end try 
      catch (Exception e) 
      { 
      } 
     }//end using 
+0

我是否需要提供本地凭据,还是可以使用具有管理权限的域凭证? – Paulo

+0

我只使用本地管理员组进行过测试。我想你也可以使用域凭据,但如果你这样做了,我会认为你部署你的应用的每个系统都需要你的域名Windows用户名作为本地系统上的Windows管理员存在? – Krondorian

相关问题