Vista를 위한 Application manifest

Vista에서 관리자 권한이 필요한 경우가 종종 있습니다.

예를 들어 Application이 Registry를 쓰거나 할 때죠.
몇몇 프로그램들은 Applicatioin의 바로가기를 마우스 오른쪽 클릭을 해서
나오는 Context Menu에 관리자 권한으로 실행을 클릭하라고
하는 경우가 있습니다.

그러나 UAC(User Access Control)에 약간 관심을 갖게 되면
manifest로 간단히 해결할 수 있습니다.

.NET Application일 경우
app.manifest 파일에 열어서
(혹은 [Application이름].exe.manifest 파일에서)

<trustInfo> 부분에
<security>에
원하시는 권한 레벨을 지정하시면 됩니다.

예를 들면 아래와 같습니다.
Visual Studio 2008 beta2에선 기본적으로 아래와 같이 되어 있습니다.

<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">
        <!-- 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" />
        <requestedExecutionLevel  level="requireAdministrator" />
        <requestedExecutionLevel  level="highestAvailable" />

            If you want to utilize File and Registry Virtualization for backward
            compatibility then delete the requestedExecutionLevel node.
        -->
        <requestedExecutionLevel level="asInvoker" />
      </requestedPrivileges>
    </security>
  </trustInfo>
</asmv1:assembly>

requestedExecutionLever을 적절히 조절하시면 레지스트리와 파일 접근에 문제가 없을 것입니다.

단, ClickOnce를 쓴다면 ClickOnce 특성상 관리자 권한을 요구하면 컴파일시 에러가 날 것입니다.

chaoskcuf
tags :
프로그래밍/TIP& Study 2007/09/03 20:45

트랙백 주소 : http://chaoskcuf.com/trackback/108

댓글을 달아 주세요

Powerd by Textcube, designed by criuce
rss