2015-10-26 76 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

相關問題