c#/MAUI

Maui windows admin 권한 얻기

Choi Jaeho 2022. 8. 14. 12:49
반응형

1,2번의 과정으로 관리자 권한을 얻을 수 있다.

 

1.

app.manifest 파일에 

<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>

구문 추가

 

<?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="MauiApp3.WinUI.app"/>

<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">

<security>

<requestedPrivileges>

<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>

</requestedPrivileges>

</security>

</trustInfo>

  <application xmlns="urn:schemas-microsoft-com:asm.v3">

    <windowsSettings>

      <!-- The combination of below two tags have the following effect:

           1) Per-Monitor for >= Windows 10 Anniversary Update

           2) System < Windows 10 Anniversary Update

      -->

      <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/PM</dpiAware>

      <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>

    </windowsSettings>

  </application>

</assembly>

 

 

---

2.

Package.appxmanifest 파일에

  <rescap:Capability Name="allowElevation" />

구문 추가

 

<?xml version="1.0" encoding="utf-8"?>

<Package

  xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"

  xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"

  xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"

  IgnorableNamespaces="uap rescap">

 

  <Identity Name="maui-package-name-placeholder" Publisher="CN=User Name" Version="0.0.0.0" />

 

  <Properties>

    <DisplayName>$placeholder$</DisplayName>

    <PublisherDisplayName>User Name</PublisherDisplayName>

    <Logo>$placeholder$.png</Logo>

  </Properties>

 

  <Dependencies>

    <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />

    <TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />

  </Dependencies>

 

  <Resources>

    <Resource Language="x-generate" />

  </Resources>

 

  <Applications>

    <Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="$targetentrypoint$">

      <uap:VisualElements

        DisplayName="$placeholder$"

        Description="$placeholder$"

        Square150x150Logo="$placeholder$.png"

        Square44x44Logo="$placeholder$.png"

        BackgroundColor="transparent">

        <uap:DefaultTile Square71x71Logo="$placeholder$.png" Wide310x150Logo="$placeholder$.png" Square310x310Logo="$placeholder$.png" />

        <uap:SplashScreen Image="$placeholder$.png" />

      </uap:VisualElements>

    </Application>

  </Applications>

 

  <Capabilities>

  <rescap:Capability Name="runFullTrust" />

  <rescap:Capability Name="allowElevation" />

  </Capabilities>

 

</Package>

반응형

'c# > MAUI' 카테고리의 다른 글

[MAUI] windows에서 실행시 전체화면 처리하기  (0) 2023.06.27