How to get current setup directory for the script section? - inno-setup

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

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 create a common desktop icon only if setupper is running elevated with admin rights

[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

cscript.exe launched by inno setup installer says cannot find file while it is right there

In my Inno setup script, I have this line:
[Files]
Source: "C:\my.vbs"; DestDir: "C:\folder"; Flags: ignoreversion
[Run]
Filename: "cscript.exe C:\folder\my.vbs"; Description: "{cm:LaunchProgram,my}"; Flags: nowait postinstall skipifsilent runascurrentuser
but when the the installation is finished, it pop up an error saying:
Unable to execute file:
cscript.exe C:\folder\my.vbs
Create process failed; code 2.
the system cannot find the file specified.
When I go to C:\folder, the my.vbs is right there, why would it say it can't find the file?
The Filename parameter, as the name says, is a path to a (executable) file to execute. What in your case is cscript.exe.
The rest are parameters of that executable, which go to the Parameters parameter.
[Run]
Filename: "cscript.exe"; Parameters: "C:\folder\my.vbs"; \
Description: "{cm:LaunchProgram,my}"; \
Flags: nowait postinstall skipifsilent runascurrentuser

How can i create a directory and copy exe file to this directory while installing my program using InnoSetup?

I have this automatic script that InnoSetup did :
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId=
AppName=VideoScreenRecorder
AppVersion=1.5
;AppVerName=VideoScreenRecorder 1.5
AppPublisher=Daniel Lipman
DefaultDirName={pf}\VideoScreenRecorder
DefaultGroupName=VideoScreenRecorder
InfoBeforeFile=D:\ScreenVideoRecorderHelp.txt
OutputDir=D:\ScreenVideoRecorderCompiler
OutputBaseFilename=Setup
SetupIconFile=D:\Activity Monitor.ico
Compression=lzma
SolidCompression=yes
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "D:\C-Sharp\ScreenVideoRecorder\ScreenVideoRecorderWorkingVersion\bin\Debug\ScreenVideoRecorder.exe"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\VideoScreenRecorder"; Filename: "{app}\ScreenVideoRecorder.exe"
Name: "{commondesktop}\VideoScreenRecorder"; Filename: "{app}\ScreenVideoRecorder.exe"; Tasks: desktopicon
[Run]
Filename: "{app}\ScreenVideoRecorder.exe"; Description: "{cm:LaunchProgram,VideoScreenRecorder}"; Flags: nowait postinstall skipifsilent
The installation take the exe file VideoScreenRecorder and copy it install it in program files directory...etc
What i want to do is to add another exe file to the installation : ffmpeg.exe
I want the installation program will create a directory at specific place for example c:\test and put the ffmpeg.exe at this directory .
The main exe file is VideoScreenRecorder.exe but i also need the ffmpeg.exe to be copied to another specific directory .
The directory where the ffmpeg.exe should be in is :
C:\Users\user name\AppData\Local\ScreenVideoRecorder\ScreenVideoRecorder\workingDirectory
I need the installation directory to create the directory at this place and then copy the ffmpeg.exe to the workingDirectory .
How can i do it ?
You can make DestDir for each file whatever you like, in this case with one of the Constants that Inno Setup has implemented.
[Files]
Source: "X:\PathToFFMPEGSource\ffmpeg.exe";
DestDir: "{localappdata}\ScreenVideoRecorder\ScreenVideoRecorder\workingDirectory";
Flags: ignoreversion
*Where X is the drive letter where your source ffmpeg.exe is located.

Recursive setting of folder permissions with InnoSetup

I have a folder tree that I copy to C:\ProgramData The software that I am installing (don't blame me for this, I did not architect, write or design it) requires full control for everyone for this data.
So I put the following line in [Files] sectionL
Source: "C:\ProgramData\PFPS\MapDataServer\*"; DestDir: "C:\ProgramData\PFPS\FalconViewCommand"; Flags: ignoreversion createallsubdirs recursesubdirs; Permissions: everyone-full; Excludes: "*.LDF"
yes, this does give everyone full control of each individual file, but the program needs to create files and the folder permissions (directory) are not set for everyone.
I tried to add a [Dirs] section but that did not work:
[Dirs]
Name: "C:\ProgramData\PFPS\FalconViewCommand"; Flags: uninsalwaysuninstall; Permissions: everyone-full
What do the guru's say?
This works for me:
[Dirs]
Name:"{app}\"; Permissions:everyone-modify
What I have been doing is the following RUN at the end, I was finding that the Dirs was not working (yes, I always do a full unistall, when testing install scripts), otherwise how do you know what will happen when the product ships?
I agree with you about {commonappdata} but I am trying to remove randomness till I get to the bottom of the issue.
Here is what I have been trying:
[Run]
Filename: "C:\Windows\System32\icacls.exe"; Parameters: "C:\ProgramData\PFPS\FalconViewCommand /grant:r Users:(OI)(CI)F"; WorkingDir: "{tmp}"; Description: "Changing Directory Permissions"; StatusMsg: "Changing Directory Permissions"

Resources