Visual Studio | 專案強制以系統管理員身分執行

Kombayar
Nov 6, 2023

--

C# WPF 專案

  1. 專案按右鍵 -> 加入 -> 新增項目 -> 選取「應用程式資訊清單檔案」。

2. 將產生的 app.manifest 修改以下內容。

diff --git a/PowerControl/app.manifest b/PowerControl/app.manifest
-<requestedExecutionLevel level="asInvoker" uiAccess="false" />
+ <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

3. 完成,建置出來的執行檔會有小盾牌。

C++ 專案

  1. 專案右鍵 -> 屬性 -> 連結器 -> 資訊清單檔 -> UAC執行層級 -> 選擇「requireAdministrator (/level=’requireAdministrator’)」。

2. 完成,建置出來的執行檔會有小盾牌。

Thanks : )

--

--

Kombayar
Kombayar

Written by Kombayar

I’m a graduate student. Self-teaching coding on Internet, wanted to write some articles to make myself remember the code.

No responses yet