프로그래밍

[vb.net] app.manifest 수정하여 관리자권한으로 실행하는 문제

프로세스 천국 2013. 3. 19. 00:07

app.manifest 파일을 기본값으로 생성하면 아래의 검은색 부분이 자동으로 들어간다.

 

여기에 파란색 부분(굵은색)을 집어넣으면 관리자로 실행안해도 된다는 얘기가 있어서 테스트 해봤는데 안된다.

 

뭐가 잘못된걸까..

 

<?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">
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <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" />

            If you want to utilize File and Registry Virtualization for backward
            compatibility then delete the requestedExecutionLevel node.
        -->
        <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
      </requestedPrivileges>
      <applicationRequestMinimum>
        <defaultAssemblyRequest permissionSetReference="Custom" />
        <PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site" />
      </applicationRequestMinimum>
    </security>
  </trustInfo>
</asmv1:assembly>

 

 

다른 방법

Imports System.Security.Principal

 

Dim uiAccess As New WindowsPrincipal(WindowsIdentity.GetCurrent())
If (uiAccess.IsInRole(WindowsBuiltInRole.Administrator) = True) Then
Else
MessageBox.Show("관리자권한으로 실행.")
End If


 

잘 생각해보니 프로그램만으로 관리자권한을 얻는게 이상한거 같다.
그렇게 되면 일반사용자의 의미가 없어지니..