10

I have an installer (Inno-Setup) that installs my application to a path defined by the user. At the end of the install routine i want to create a shortcut that starts the application with admin privileges. The solution should work on all win version from winXP to Win7.

What can i do to achieve this?

I know that it is possible with a batch script, that executes a nasty vb-script. The disadvantage is that the cmd-window popup and it only works on win7 i guess.

I also tried the command mklink to create a hyperlink, but it does not work because it is not possible to pass an argument that set the admin priviliges.

4

4 に答える 4

13

プログラムを管理者として実行するように Windows に指示するレジストリ キーを追加できます。

の下に、値を持つHKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layersキー (REG_SZ) を追加するだけです。exe を起動すると、管理者アクセスを求められます。<Path to your exe>RUNASADMIN

これにより、Inno-Setup で行うように、実行可能ファイルへの通常のショートカットを簡単に作成できます。

cmd またはバッチファイルを介してこれを行う場合は、次のコマンドを使用できます。

reg add "HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v "<Path to your exe>" /t REG_SZ /d RUNASADMIN
于 2013-04-18T13:46:37.117 に答える
0

ショートカットを作成したら、21 バイト目 (位置 0x15) を 32 (0x20) に変更して、「管理者として実行」にします。0 に戻すと、「通常の」(管理者以外の) ショートカットになります。

于 2018-08-23T15:55:19.270 に答える