私のインストーラーは、インストールされている Windows サービスでいくつかの基本的な構成を行うために使用される構成 exe を展開します。exe は、いくつかのレジストリ キーを作成して書き込む必要もあります。Windows サーバー 2008 環境では、これらのキーを作成できません。調査したところ、これは管理者権限であり、exe は 2008 年の UAC で必要な管理者権限を求めていません。exe を右クリックして管理者として実行することで、これを回避できます。これは理想的ではありませんが、実行したことをクライアントに通知する必要がある追加の手順です。exe の実行時に管理者権限を昇格させる他の方法はありますか?
1 に答える
1
マニフェストをexe上またはexeとともに配置します。使用しているバージョンを教えていただければ、VisualStudioを使用してマニフェストを埋め込む方法を教えていただけます。Visual Studioを使用していない場合、またはexeをビルドしていない場合は、マニフェストファイルをexeと同じフォルダーに置くだけで、それも機能します。その場合、ファイルにはexeと同じ名前を付け、最後に.manifestを付ける必要があります。たとえば、foo.exeの場合はfoo.exe.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">
<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" 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>
</security>
</trustInfo>
</asmv1:assembly>
requestedExecutionLevelの可能な値はすべてコメントにあり、これはrequireAdministratorを使用していることに注意してください。今、それは常に上昇し、したがってあなたのために働きます。
于 2010-06-04T10:24:21.213 に答える