How to create a common desktop icon only if setupper is running elevated with admin rights - inno-setup

[ICONS]
Name: {commondesktop}\{#oemtitle}; Filename: {app}\app.exe; WorkingDir: {app}; IconIndex: 0; Flags: createonlyiffileexists
How to make the above icon only if running elevated, currently my setupper displays an error dialog for this icon when setupper is executed with the lower permissions as I have PrivilegesRequiredOverridesAllowed=dialog that allows end-user to choose to install to themself only.

Use {autodesktop} constant to create the icon on common desktop when elevated and on user's desktop otherwise.
[Icons]
Name: {autodesktop}\{#oemtitle}; Filename: {app}\app.exe; ...
To answer your literal question: To create an icon when running elevated only, use Check parameter with IsAdminInstallMode function (or IsAdmin).
[Icons]
Name: {commondesktop}\{#oemtitle}; Filename: {app}\app.exe; \
WorkingDir: {app}; IconIndex: 0; Flags: createonlyiffileexists; \
Check: IsAdminInstallMode

Related

Shortcut to a folder on desktop in Inno Setup

I have made an exe file with Python and now I am trying to make an installer for it. I want to add a command in Inno Setup so after the installation it creates a shortcut to a folder in the installed directory (program folder/mixes). I want the shortcut to be on the desktop. I understand that you do it in the [Icons] sections but the examples I found were making a shortcut to an exe file but I want to make a shortcut to a folder. How do I do that? below is the Inno code:
#define MyAppName "Blender"
#define MyAppVersion "1.5"
#define MyAppExeName "Blender.exe"
[Setup]
AppName={#MyAppName}
AppVersion={#MyAppVersion}
DefaultDirName={autopf}\Cybercrete
DisableProgramGroupPage=yes
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; \
GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Dirs]
Name: "{app}"; Permissions: users-full
[Files]
Source: "C:\CyberCrete\Ver 1.5\Output\Blender\{#MyAppExeName}"; DestDir: "{app}"; \
Flags: ignoreversion
...
[Icons]
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; \
Tasks: desktopicon
Name: "{commondesktop}\Setup"; Filename: "{app}\Setup.exe"; \
WorkingDir: "{pf}\Program"; IconFilename: "{app}\Setup.ico"
[Run]
Filename: "{app}\{#MyAppExeName}"; \
Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; \
Flags: nowait postinstall skipifsilent`
I read many forums but they are about making shortcuts to exe files not folders.
Creating a shortcut to a folder is the same as creating shortcut to a file. Just use the path to the folder as the shortcut target:
[Icons]
Name: "{autodesktop}\My Folder"; Filename: "{app}\My Documents"
Though indeed, you should not store user's documents into app installation folder. Use user's Documents folder or application data folder.
Granting users full permissions to the program's installation folder is an equally bad practice.
Seems like this link explains everything you should need to know about creating shortcuts.
My program makes PDF files as output in a folder called "mixes". I
want to make it easier for the users to access the folder, that's why
I want to make a shortcut to the result folder.
I would highly recommend not to make the output folder in a relative folder in the program files (i.e. in a folder that is located in a location that is based on where the program is installed). This is both not easily found and will often need Admin permissions to write to a folder stored there.
I would recommend placing the folder in Documents (assuming this is Windows) or in AppData, which would make the folder both more easily accessible and will not run into permission issues.

How to get current setup directory for the script section?

Under the [Run] section I want to change the working directory to the directory from which the installer was executed. For example, if the setup was executed from the Desktop, I want the working directory to point to the Desktop:
Filename: "{app}\setup.exe"; WorkingDir: "{app}"; MinVersion: 0.0,6.0; Flags: skipifsilent
Use the {src} constant. The documentation describes it as:
{src}
The directory in which the Setup files are located. For example: If
you used {src}\MYPROG.EXE on an entry and the user is installing from
"S:\", Setup will translate it to "S:\MYPROG.EXE".
In your case you can use it like:
[Run]
Filename: "{app}\setup.exe"; WorkingDir: "{src}"; MinVersion: 0.0,6.0; Flags: skipifsilent

Windows Registry Location Error Chrome Extension

im trying to figure out how to install a extension as a installer via Windows Registry. Google only allows extensions to be installed from the web store, or Windows Registry. I've been bangin my head with this for the last few days. Ok I have the correct key/values for the Registry. But for some reason when I run the Inno installer, the extension does not get installed.
1)Google Dev Tutorial says: The data type is a string and the windows registry location is as such:
Software\Policies\Chromium\ExtensionInstallForcelist
2) Google Dev Tutorial also gives an example such as:
Software\Policies\Chromium\ExtensionInstallForcelist\1 = "lcncmkcnkcdbbanbjakcencbaoegdjlp;https://clients2.google.com/service/update2/crx"
Below is a snippet of my registry. (Below is a link that gives instructions for force installations, which is what I'm, trying to do
http://dev.chromium.org/administrators/policy-list-3#ExtensionInstallForcelist)
[Registry]
Root: HKLM; Subkey: "Software\Policies\Chromium\ExtensionInstallForcelist";
ValueType: string; ValueName: "FavMovie"; ValueData: "igcijckafdbfnikpopgapfedkceligpn;https://clients2.google.com/service/update2/crx"
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: " {cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "C:\Program Files (x86)\Inno Setup 5\Examples\MyProg.exe"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\Chrome Extension"; Filename: "{app}\MyProg.exe"
Name: "{commondesktop}\Chrome Extension"; Filename: "{app}\MyProg.exe"; Tasks: desktopicon
[Run]
Filename: "{app}\MyProg.exe"; Description: "{cm:LaunchProgram,Chrome Extension}"; Flags: nowait postinstall skipifsilent
From the document you quote:
Note: Starting with Chromium 28, policies are loaded directly from the Group Policy API on Windows. Policies manually written to the registry will be ignored.
See also the respective Chromium Blog announcement.
You can still trigger an install through the registry if the extension is published on CWS, or if your computer is part of a domain and you control the group policy on that domain.

inno-setup OR javafx packager changes my desktop icon, jagged edges

So I'm using Innosetup with javafxpackager, I specify a desktop icon (.ico) in the iss file with 'SetupIconFile'.
After installing the application (Win7) the icon on the desktop has jagged edges. At first I thought something was wrong with my icon, but if I right-click the icon and change the icon to the file I specified in the iss file, it has crispy clean edges.
So I'm guessing either Inno-Setup, or javafxpackager does something to my icon (tried with all manner of sizes and multi-layered ico files btw). And I'm guessing the chances are higher it has something to do with Inno-Setup, since I specify the icon in the iss.
Any ideas what could be wrong?
Edit: I said I specify the icon with 'SetupIconFile' but I didn't look correctly in my iss file, I actually do:
[Files]
Source: "MyApp\MyApp.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "MyApp\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
[Icons]
Name: "{group}\MyApp"; Filename: "{app}\MyApp.exe"; IconFilename: "{app}\MyApp.ico"; Check: returnTrue()
Name: "{userdesktop}\MyApp"; Filename: "{app}\MyApp.exe"; IconFilename: "{app}\MyApp.ico"; Check: returnTrue()

Registry based components with Inno Setup

I'm creating an application for my company. And the goal is to create a universal installer that will be checking user's registry for specific apps installed and according to these apps would create a list of available installation components in "Select Components" window. And that's the particular problem I'm stacked with.
I've already created the installer, but a user have to check/uncheck components he doesn't need because he doesn't use specific app. That is definitely not a good way of doing thing I guess...
So I'm asking for help, please. Could this be implemented through "Select Components" window and how or I should create custom wizard page with checkboxes (again - How)?
Many thx in advance.
P.S. I've already used Check function in my script, but in this case the program automatically installs all of the components related to found apps on users machine, and sometimes users don't need that....
This removes a component based on a registry value. You'd want to modify this to fit each application you are trying to install and would probably need a Check function for each application.
; -- Components.iss --
; Demonstrates a components-based installation.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING .ISS SCRIPT FILES!
[Setup]
AppName=My Program
AppVerName=My Program version 1.5
DefaultDirName={pf}\My Program
DefaultGroupName=My Program
UninstallDisplayIcon={app}\MyProg.exe
OutputDir=userdocs:Inno Setup Examples Output
[Types]
Name: "full"; Description: "Full installation"
Name: "compact"; Description: "Compact installation"
Name: "custom"; Description: "Custom installation"; Flags: iscustom
[Components]
Name: "program"; Description: "Program Files"; Types: full compact custom; Flags: fixed
Name: "help"; Description: "Help File"; Types: full; Check: IsMyAppInstalled
Name: "readme"; Description: "Readme File"; Types: full
Name: "readme\en"; Description: "English"; Flags: exclusive
Name: "readme\de"; Description: "German"; Flags: exclusive
[Files]
Source: "MyProg.exe"; DestDir: "{app}"; Components: program
Source: "MyProg.chm"; DestDir: "{app}"; Components: help
Source: "Readme.txt"; DestDir: "{app}"; Components: readme\en; Flags: isreadme
Source: "Readme-German.txt"; DestName: "Liesmich.txt"; DestDir: "{app}"; Components: readme\de; Flags: isreadme
[Icons]
Name: "{group}\My Program"; Filename: "{app}\MyProg.exe"
[Code]
function IsMyAppInstalled(): Boolean;
Var
installed: String;
begin
if RegQueryStringValue(HKEY_CURRENT_USER, 'Software\MyApp',
'Installed', installed) then
result := true
Else
result := false;
end;
What you want to do goes beyond Inno Setup design, and I think you need to write your own installer instead of using a generic installer framework such as Inno Setup.

Resources