UAC全名又為User Account Control,其功能會限制程式的權限,並降低病毒或惡意程式的風險
UAC又有分三個等級,requireAdministrator、highestAvailable以及asInvoker
requireAdministrator:要求取得最高管理者權限
highestAvailable:會取得目前的使用者權限,如果有要用到管理者權限則會提示
asInvoker:一般程式權限
有找到一篇比較requireAdministrator與highestAvailable之間差異的文章『Difference between “highestAvailable” and “requireAdministrator” in manifest in terms of Elevation?』,有興趣的人可以看一下
在目前專案按下右鍵/加入/新增項目
選擇『應用程式資訊清單檔案』
再依程式權限去調整就好了
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<!-- UAC 資訊清單選項
如果您要變更 Windows 使用者帳戶控制層級,請將
requestedExecutionLevel 節點取代為下列其中一項。
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
指定 requestedExecutionLevel 節點會停用檔案和登錄虛擬化。
如果您要針對回溯相容性使用檔案及登錄虛擬化,
請刪除 requestedExecutionLevel 節點。
-->
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- 可配合此應用程式使用的所有 Windows 版本的清單。Windows 會自動選取最相容的環境。-->
<!-- 如果您的應用程式是設計成配合 Windows 7 運作,請取消註解下列 supportedOS 節點-->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
</application>
</compatibility>
<!-- 啟用 Windows 通用控制項和對話方塊的佈景主題 (Windows XP 以後版本) -->
<!-- <dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>-->
</asmv1:assembly>
參考資料:
http://code.msdn.microsoft.com/windowsdesktop/CSUACSelfElevation-644673d3
http://en.wikipedia.org/wiki/User_Account_Control
http://gelis-dotnet.blogspot.tw/2009/06/manifestvista.html
http://msdn.microsoft.com/zh-tw/library/bb384608.aspx
http://technet.microsoft.com/en-us/library/0d75f774-8514-4c9e-ac08-4c21f5c6c2d9
http://technet.microsoft.com/en-us/library/00d04415-2b2f-422c-b70e-b18ff918c281

