Inno Setup silently fails to install files - inno-setup

We have an installer created with Inno Setup for installing our VBA add-in and associated files on computers where users do not have administrator privileges.
The destination directory for these files is {userappdata}\Microsoft\AddIns\our-addin-name. In a typical Windows set up this works. However, on some organisations' computers this silently fails: the installer runs, and the dialog is showing the correct destination directory when it is extracting the files, but when you look into the destination directory there is nothing there.
Further comments on one particular case
When the IT administrator had helped the user to run the installation, the installation was successful (presumably he'd run the installer with elevated privileges). However, following a restart, the add-in had gone, and the destination directory {userappdata}\Microsoft\AddIns\our-addin-name is not present.
The user does appear to have write access to {userappdata}\Microsoft\AddIns - the add-in saves data in another directory it creates there - and this was present (i.e. it looks like the system is not trusting files that come from the installer, whilst it is trusting files generated from the add-in). We save data in that directory (as well as a copy in the user's home directory) to get over a problem in some systems where directories appear to be purged in the user's appdata directory between restarts - at least in some systems, this doesn't apply to {userappdata}\Microsoft
Questions/possible solutions
It doesn't seem that the Inno Setup installer is checking whether files are successfully saved in the target directory. What I intend to do is have the installer try to install one of its files into {userappdata}\Microsoft\AddIns, check if it was actually saved there, if not, try another directory - e.g. the user's home directory, and do another check. Then to continue with the installation with whichever path was successful, or otherwise display a message.
I should be able to achieve this with Pascal scripting by extracting one of the files to the temporary directory, attempting to copy that to the target directory and checking to see if the file exists in the target directory.
Does this seem like a reasonable approach?
Minimal reproducible example
I am not able to/do not know how to reproduce the problem on my own machine, and I do not have access to the machines where the problem has been reported. Below is a minimal version of what I am trying to do - and which should fail on problem machines (but does not fail on my own):
#define MyAppName "VBA Addin Install Minimal"
#define MyAppVersion "1.5"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "http://www.example.com/"
[Setup]
AppId={{E33BF27B-5E1D-4432-B75E-BDA757746A6F}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={userappdata}\Microsoft\AddIns\FileInstallTest
DisableDirPage=yes
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
DisableWelcomePage=no
OutputDir=compiled-iss
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
PrivilegesRequired=lowest
SetupLogging=yes
Uninstallable=no
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Files]
Source: "install-files\show-a-message.ppam"; DestDir: "{userappdata}\Microsoft\AddIns\FileInstallTest"; DestName: "show-a-message.ppam"
Logging
On my machine the installation goes to plan - and the log file indicates that. I have set SetupLogging=yes so that I can get a better idea of what's going on when/if it is reported in the future.

Related

Inno Setup: shared files are not being deleted from my install directory

I have created an installer using Inno 5.5.9 and am installing a number of binary files that need to be marked as shared because a second installer could install a second program to the same directory and these files are common across the two programs.
I am marking the files with the flags 'sharedfile uninsnosharedfileprompt' but they are not removed on uninstall even if they are not in use.
In my testing I install the main program and then uninstall it immediately. The uninstall log says it is 'decrementing shared count' for these files but the shared count is not reaching zero. This is a 32bit program installed onto Windows 10.
#define SourceDirectory "..\bin2017\win32"
#define InstallPath "{app}\bin\Win32\"
[Files]
Source: "{#SourceDirectory}\*.dll"; DestDir: "{#InstallPath}"; Flags: ignoreversion sharedfile uninsnosharedfileprompt
What am I missing to make this work correctly? What could be preventing the uninstaller from decrementing the shared count to zero?
If you need any more info or code please let me know (this is my first question on the excellent site).
Thanks in advance.
The path in the original location has most likely some orphan reference.
I believe your code is correct and the installer behaves correctly. It's just a local problem with reference counting.

Download files from fileshare [duplicate]

Is it possible to create the Inno Setup script to copy files from a UNC path on the network rather than statically adding them to the setup file?
If so, can it still be done if I need to authenticate to the path first? Is there a mechanism to provide authentication info in the Inno Setup script?
Essentially, I am wanting setup to just copy files from various sources over the intranet from a UNC path to put into the setup destination directory.
Yes, specify the UNC path in the Source parameter of the [Files] section entry and use the external flag.
[Files]
Source: \\UNC\path\file.txt; DestDir: {app}; Flags: external
To authenticate, you would have to call the WNetUseConnection or similar WinAPI.
See How to execute "net use" command from Inno Setup installer on Windows 7?

How to recursivelly include folder/files using a wildcard in Inno Setup

I want to include language resource files from our build into our installers. The language resource files all have the same name, but reside in different sub-folders (one per locale), like this:
\Release
\bin
\es-MX
Localization.resources.dll
\fr-CA
Localization.resources.dll
etc.
In my [Files] section, I thought perhaps I might be able to do this (note the position of the asterisk):
Source: "..\\source\\Libraries\\Localization\\bin\\Release\\*\\Localization.resources.dll"; \
DestDir: "{app}\\MyApp"; Flags: ignoreversion recursesubdirs
Unfortunately, Inno Setup blows up, complaining that it can't find any files:
Compiler Error!
Line 129: No files found matching "C:\Development\HT\Installers\..\source\Libraries\Localization\bin\Release\*\Localization.resources.dll"
I would like Inno Setup to look for any sub-folder (hence the *) containing a file named Localization.resources.dll and upon installation, create a language directory with the same name (based on what is found via the wildcard) and copy the file to that folder, doing so for each folder that matches the criteria.
Essentially, I want to end up with this:
..
\MyApp
\es-MX
Localization.resources.dll
\fr-CA
Localization.resources.dll
In case it isn't obvious, I would prefer not to explicitly add the source and destination folder names, because we will be adding more languages/locales in the future, and I would like Inno Setup to automatically pick up any new language folders/files we create without having to change the installer source.
Is this possible?
Just use the recursesubdirs flag with a root path to a tree and the Localization.resources.dll filename. It will automatically do what you want: find all Localization.resources.dll files in the tree and install them to their respective subfolders:
Source: "..\source\Libraries\Localization\bin\Release\Localization.resources.dll"; \
DestDir: "{app}\MyApp"; Flags: ignoreversion recursesubdirs
As documented (emphasis mine):
recursesubdirs
Instructs the compiler or Setup to also search for the Source filename/wildcard in subdirectories under the Source directory.
Other possible approaches:
Generate the Files section using a preprocessor.
For a similar tasks, see:
Inno Setup - Recurse sub directories without creating those same sub directories
Generating Inno Setup file flags programmatically
Inno Setup: Dynamically add a component for all files in a folder and its subfolders
Generate the Files section using an external scripting language (with better functionality then Inno Setup preprocessor) and invoke it using the Exec preprocessor function. E.g. using PowerShell.

Inno Setup copy OutputBaseFileName in PostCompile section

I want copy OutputBaseFileName to archive after Inno Setup Studio script compiling is finished.
I prepared this script but it doesn't work.
[PostCompile]
Name: CopyFile({#OutputBaseFilename}, '\\Bckserver\Source\'{#OutputBaseFilename});
I will guess that you want to have the compiler copy the generated installer to yet another directory (\\Bckserver\Source).
This works:
Name: "C:\Windows\System32\cmd.exe"; Parameters: "/c copy C:\path\setup.exe \\Bckserver\Source"
I do not think there's better solution, as Inno Setup Studio does not support preprocessor in the PostCompile section, so you cannot refer to OutputBaseFilename or system directory other than by hard-coding them.

InnoSetup - Erroneous "File in use by another process..." message while compiling

Although I really like InnoSetup, I have been suffering with this erroneous message for some time, but my frustration has reached new heights. There are numerous posts complaining about this problem, which is most certainly an InnoSetup bug, but no useful work-arounds that I can find.
I have a very simple (signed) setup that merely copies some files and creates a shortcut. It does not even include an executable. When I try to compile the setup, I am getting this "the process cannot access the file because it is being used by another process" message - repeatedly (normally I always get the setup to compile within 3 tries), but now it seems futile after many. many tries. The file that is "in-use" is not clear from the InnoSetup output or error dialog. There are most definitely no competing processes running. (I have rebooted the machine and still get this message).
Any ideas on how to resolve this are much appreciated.
Here is the complete setup code - it is signed, but that is not a problem with other setups I have created with the same signature.
#define MyAppName "Easy-IAP for IronKey"
#define MyAppVersion "4.0"
#define MyAppPublisher "Command Post Solutions"
#define MyAppURL "http://www.commandpostsolutions.com/"
[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={{51668D56-27F6-4C83-87F2-677328EFE808}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName="\EZ-IAP"
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
OutputBaseFilename=IronKeySetup
SetupIconFile=C:\Users\ron\Dropbox\EZIAP\eziap.ico
Compression=lzma
SolidCompression=yes
SignedUninstaller=yes
SignTool=Standard /d $qEasy-IAP Installer$q $f
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Files]
Source: "C:\Users\ron\Dropbox\Easy-IAP for IronKey\AccessDatabaseEngine.exe"; DestDir: "{app}"; Flags: onlyifdoesntexist
Source: "C:\Users\ron\Dropbox\Easy-IAP for IronKey\dotNetFx40_Full_x86_x64.exe"; DestDir: "{app}"; Flags: onlyifdoesntexist
Source: "C:\Users\ron\Dropbox\Easy-IAP for IronKey\Easy-IAP for IronKey\bin\Release\Easy-IAP for IronKey.exe"; DestDir: "{app}";
; NOTE: Don't use "Flags: ignoreversion" on any shared system les
[ICONS]
Name: "{drive:{app}}\Easy-IAP"; Filename: "{app}\Easy-IAP for IronKey.exe";
I had the same problem.
It was due to McAfee antivirus running the realtime scanning on the exe file being compiled...
As it doesn't seem possible to exclude a directory from realtime scanning, I shut it down in McAfee SecurityCenter, and now it's good.
Hope this help
The problem is often an explorer window being open viewing the folder where the output files will reside.
Explorer continually opens the executable as it is built trying to fetch its icon and other metadata. Close any open explorer windows which are viewing the output folder and try again.
For this reason you are best running your inno setup file from the command line or part of a visual studio or other automated build process.
This is not a bug, this is only bad design of application (or bad documentation) :)
Use the OutputDir directive in your [Setup] section to avoid this wrong behaviour.
OutputDir=c:\output
OutputDir specifies the "output" directory for the script, which is where the Setup Compiler will place the resulting SETUP.* files. By default, it creates a directory named Output under the directory containing the script for this.
You ask why?
If you do not use OutputDir in your script file (and many people do not use it) Inno Setup tries to create resulting setup in the "userdocs:" folder which causes a lot of troubles on all Windows systems.
Always use this parameter, even if you want to have resulting setup in current folder, in that case use:
OutputDir=output
I have OutputDir = x:]setup but the error still occurs. If I reboot my machine and then build as the 1st task then the build works.
Win 7 Pro/64, InnoSetup 5.5.5(a): I had axactly the same InnoSetup compilling problems. After changing folders properties used in projects and output by revoking sharing them all works fine. Conclusion - it is better not to use InnoSetup within shared folders.
I had this when OutputDir="." (meaning, put the output in the same directory as the source files). It would fail every second build.
I fixed it by adding modifying my powershell build script to delete that entire output directory, then build my app (which auto-created that directory), then run iscc to create the setup.exe
The error could be caused because you are trying to copy a folder that is linked with a Windows Service.
To solve this problem, use a [Code] section instead of putting the folder in [Files]. That allows you to check if the folder exist, close the associated windows service and finally copy the folder.
I had the same problem with that the solution is already stated above
and the other reason with this error comes up when the output file of the .exe you compiling has already have the same name in the directory where you put the output directory from inno setup.
In order words when compiling you need some special character like '-' or '_' in creating the file name and to avoid this error message.
I tried various folders on my work machine and nothing resolved the issue. I finally had success by using:
OutputDir=C:\Users\userid\Downloads
(Replace "userid" with your particular account)
I tried all advices from above. I could not make it.
Then I switched back from version 6.2 to 6.0.2 and it fixed the problem.

Resources