先在 Project 內新增 應用程式清單檔案 (app.manifest)
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<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">
<!-- UAC 資訊清單選項
如果要變更 Windows 使用者帳戶控制層級,請將
requestedExecutionLevel 節點以下列其中之一取代。
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
指定 requestedExecutionLevel 項目會停用檔案及登錄虛擬化。
如果您的應用程式需要針對回溯相容性進行這項虛擬化,請移除這個
項目。
-->
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>設定完成後,執行檔案圖示右下角就會有個盾牌出現
![[C#] 以系統管理員身分執行此程式-1](https://live.staticflickr.com/65535/50518391058_5af0c73f0a_z.jpg)
![[C#] 以系統管理員身分執行此程式-3](https://live.staticflickr.com/65535/50518391038_c527a8e5ef_n.jpg)
![[C#] 以系統管理員身分執行此程式-2](https://live.staticflickr.com/65535/50518391033_1fd513cacb.jpg)
沒有留言:
張貼留言