views:

444

answers:

1

Hi,

using INNO Setup I currently have the following entry under the [ICONS] section:

Name: "{group}\My App\My App - Command Prompt"; Filename: "cmd.exe"; WorkingDir: "{app}"

This shortcut launches a command prompt straight into my application's folder. Unfortunately it isn't launched as elevated which means the commands the user runs from there doesn't have appropriate rights.

Using INNO Setup, how can I create a shortcut to CMD.exe (in a specific folder) that requires elevation?

Doing this for other applications can be done via a manifest file. My question is, how do I use it using INNO, and if I can't, what are my alternatives?

+1  A: 

The administrative property of a shortcut is a compatibility setting, you're not supposed to set it programmatically. The commands the user runs should ask for administrative privileges themselves by having the proper manifest. The user can also choose to elevate themselves by right clicking on the shortcut and choosing Run As Administrator.

If you always want to elevate immediately anyway, you could place a little utility in your application folder marked with an administrative manifest. All this utility would do is spawn cmd.exe. That way you can avoid messing with compatibility settings.

If you still want to use the compatibility settings, take a look at the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers and HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers registry keys. You can also use Inno Setup's built in IUnknown support, but this is more work. See the CodeAutomation2.iss example script and http://social.msdn.microsoft.com/Forums/en-US/windowssecurity/thread/a55aa70e-ae4d-4bf6-b179-2e3df3668989

mlaan

related questions