C#程式以「系統管理者身分」執行 (UAC)
下午3:15C#程式以「系統管理者身分」執行 (UAC)
這個問題很有趣,有三個解法
1. build完後,在app上按右鍵選「系統管理者身分」執行.
2. build完後,在app的properties->Capability 選以系統管理者身分執行
3. 在VS的專案中右鍵選 Add->Add New Item->Vistual C# item中選generic -> Application Manifest file
確定後 把requestedExecutionLevel 改成 requireAdministrator, uiAccess改成true 如下,接者按REBUILD 就ok了
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Specifying requestedExecutionLevel node will disable file and registry virtualization.
If you want to utilize File and Registry Virtualization for backward
compatibility then delete the requestedExecutionLevel node.
-->
<requestedExecutionLevel level="requireAdministrator" uiAccess="true" />
</requestedPrivileges>
參考
http://www.dotblogs.com.tw/jjnnykimo/archive/2009/05/08/8346.aspx
0 意見