Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inno Setup and the Windows UAC shield

Tags:

uac

inno-setup

I am stuck at some UAC issue (I guess).

My question is: What does this UAC Shield Icon on some applications mean? And how would I get this icon to my Inno Setup setup.exe?

like image 350
Christian Rockrohr Avatar asked Jan 24 '13 10:01

Christian Rockrohr


People also ask

What is Inno setup used for?

Inno Setup is an open source script-driven installation system created in Delphi by Jordan Russell. The Inno Setup Extensions Knowledge Base (ISXKB) aims to support users of this installation system by providing a source of information, code snippets, guide lines, and ready-to-use solutions.

What is an Inno Setup file?

Inno Setup is a free software script-driven installation system created in Delphi by Jordan Russell. The first version was released in 1997.

How do I Setup Inno Setup?

Go to Menu, Project, then Compile to compile and create the setup file. This will create a complete installer. Run the Setup and your application will be installed correctly. Innosetup offers an awesome alternative to create great looking Installers for free.

Does Inno setup work on Linux?

You're in luck: It's possible to run Inno Setup anywhere that Docker runs (including Linux and macOS), and even have a passable experience writing your setup script.


2 Answers

Inno Setup installers require Admin Privileges by default (if not customized by installer creator). UAC popup will be triggered if user did not change UAC settings in Windows.

http://www.jrsoftware.org/ishelp/index.php?topic=setup_privilegesrequired

[Setup]: PrivilegesRequired

Valid values: none, poweruser, admin, or lowest

Default value: admin

Description: The effect of this directive depends on which version of Windows the user is running:

like image 150
RobeN Avatar answered Oct 14 '22 16:10

RobeN


As others have said, Inno Setup requires administrator privileges by default, and will trigger the UAC prompt. You can change that with PrivilegesRequired. The problem with this is that it doesn't show the shield icon on the executable.


The best way to do it is to use the Microsoft's Manifest Tool and change the manifest embedded in the executable. It is usually included in Microsoft SDKs, which are free to download from Microsoft. Once you install it, the Manifest Tool is usually located in C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\bin\mt.exe. Note that some SDKs don't include it. I also found it in https://github.com/eladkarako/mt, if you don't want to install the SDK.

  • To extract the manifest from the executable, execute this in the command line: "path to mt.exe" -inputresource:"path_filename.exe";#1 -out:"path_filename.exe.manifest"
  • Now change asInvoker to requireAdministrator in path_filename.exe.manifest (manifest files are actually XMLs, so you can edit them with a text editor)
  • To put the manifest into the executable: "path to mt.exe" -manifest "path_filename.exe.manifest" -outputresource:"path_filename.exe";1

There you go! The executable now has the shield icon no matter what!


There's another method, which is far less useful. You can change the executable to run as administrator in the registry (same as right clicking it --> Properties --> Compatibility --> checking Run as Administrator on). To do this, create a string value that has the name set as the path+filename of the executable, and contains the data/text RUNASADMIN; the value has to be created in:

  • HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers if you want to change it for the current user
  • HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers if you want to change it for all users (this usually requires you to have administrator privileges)

The problem with it is that it doesn't carry over if you move the executable (you have to do it all over again) or give it to someone else (they have to do it, or have to run some tool to do it). This is not useful.

like image 1
Quirinus Avatar answered Oct 14 '22 16:10

Quirinus