I've got the following script...
[Files]
Source: "extractor.prop"; DestDir: "{app}"
How can I say, if extractor.prop already exists, rename it to extractor.prop.old and install this one? By default at the moment it just deletes the old file so I don't want to erase the file if it's currently in use on a customer's site.
Use another [Files] entry with the external flag:
[Files]
Source: "{app}\extractor.prop"; DestDir: "{app}"; DestName: "extractor.prop.old"; Flags: external skipifsourcedoesntexist
This is what external does:
external
This flag instructs Inno Setup not to statically compile the
file specified by the Source parameter into the installation files,
but instead copy from an existing file on the distribution media or
the user's system. See the Source parameter description for more
information.
(source)
Related
I have a Windows service that runs as the local system account. It stores some data in its %LOCALAPPDATA% folder. For LocalSystem, this is the following location:
C:\Windows\system32\config\systemprofile\AppData\Local
This works without a hitch; the service creates its own subfolder and writes files to it.
Now, using Inno Setup, I'm trying to install an initial file to that folder:
[Files]
Source: "LICENSE"; DestDir: "{sys}\config\systemprofile\AppData\Local\InnoTest"; Flags: ignoreversion
The log suggests that this works fine:
[14:20:10,722] -- File entry --
[14:20:10,725] Dest filename: C:\Windows\system32\config\systemprofile\AppData\Local\InnoTest\LICENSE
[14:20:10,729] Time stamp of our file: 2022-10-24 13:56:42.000
[14:20:10,731] Installing the file.
[14:20:10,734] Creating directory: C:\Windows\system32\config\systemprofile\AppData\Local\InnoTest
[14:20:10,738] Successfully installed the file.
It says "successfully installed the file", but neither the file nor the directory is anywhere to be seen.
Run the installer again, however, and you will be told that the destination file exists:
[14:24:47,381] -- File entry --
[14:24:47,395] Dest filename: C:\Windows\system32\config\systemprofile\AppData\Local\InnoTest\LICENSE
[14:24:47,398] Time stamp of our file: 2022-10-24 13:56:42.000
[14:24:47,400] Dest file exists.
[14:24:47,403] Time stamp of existing file: 2022-10-24 13:56:42.000
[14:24:47,405] Installing the file.
[14:24:47,410] Successfully installed the file.
So: The installer thinks the file exists, but I can't see it.
This is specifically an issue with the System account; if I switch to, say, the %LOCALAPPDATA% of the LocalService account, things work as expected:
[Files]
Source: "LICENSE"; DestDir: "{win}\ServiceProfiles\LocalService\AppData\Local\InnoTest"; Flags: ignoreversion
If anyone could shed some light on what is (or isn't) going on here, it would be much appreciated.
Minimal, reproducible and complete example here.
This is almost a duplicate of:
File/DLL installed to {sys} does not appear in C:\Windows\system32
Though your question probably deserves specific answer.
If I understand correctly, you want to install to System32 on both 32-bit and 64-bit systems. So there are two options:
Use the 64-bit mode;
If you do not want (or not dare) to switch whole installer to 64-bit mode, you will need two entries in the [Files] section. One for 64-bit systems with 64bit flag and one for 32-bit systems without the flag:
[Files]
Source: "LICENSE"; \
DestDir: "{sys}\config\systemprofile\AppData\Local\InnoTest"; \
Flags: ignoreversion; Flags: 64bit; Check: IsWin64
Source: "LICENSE"; \
DestDir: "{sys}\config\systemprofile\AppData\Local\InnoTest"; \
Flags: ignoreversion; Check: not IsWin64
I want to register an EXE file as OLE server with Inno Setup.
When I use my EXE file path with Regserver parameter in cmd, everything is correct.
But when I use the regserver flag in Inno Setup like this:
Source: "{src}\App\MyApp.exe"; DestDir: "{app}"; Flags: external regserver
I got this error
Unable to register the DLL/OCX: Regsvr32 failed with exit code 0x4.
What should I do?
The regserver flag is for DLL/OCX files only. There's no standard way to register EXE files, so it cannot be handled natively by Inno Setup, the same way you cannot use regsvr32 with an EXE file.
If your EXE file has a custom command-line parameter for the registration, use it in Inno Setup in the Run section:
[Run]
Filename: "{app}\MyApp.exe"; Parameters: "Regserver"
I have created an installer using innosetup. Where User can choose the directory where he wants to install by setting up DisableDirPage=No but when it comes to patch installers it is failed to update as user has been installed the app to his preferred directory. How to make installer to identify in which directory the app has been installed and make the patch installer to work.
installer code:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
DefaultGroupName=My Program
UninstallDisplayIcon={app}\MyProg.exe
Compression=lzma2
SolidCompression=yes
OutputDir = c:\test
OutputBaseFilename=update
DisableDirPage=No
[Files]
Source: "MyProg.exe"; DestDir: "{app}"
Source: "MyProg.chm"; DestDir: "{app}"
Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme
[Icons]
Name: "{group}\My Program"; Filename: "{app}\MyProg.exe"
If I unterstand you correctly you are talking about the setuo for your own application. You can put the UsePreviousAppDir directive in your [Setup] section. It's not necessary because its default value is 'yes' anyway. The documentation (http://jrsoftware.org/ishelp/) says that the Setup is looking for the same application, which is defined by the AppId or the AppName.
As long as you use AppName=My Program like in your example code, Inno Setup should find the install path of the old version itself. But if the AppName or AppId changes in your new version, there is no way to find it in the registry. A changing AppId is likely if you use a new guid for every setup.
I'm trying to create an installer with Inno Setup that will statically include a folder if it exists. This folder will be installed on the user system if a specific directory already exists on the user's system.
For example, there are configurations specific to 2017, 2018, 2019. If I have a CC2017 folder, then include it in the installer. The installer will put the folder on the user's system in their 2017 folder if it exists.
I use variables to define some of the path and have formatted them without brackets based on the answer here.
#ifexist projpath + "\" + reponame + "\Plug-Ins\Windows\CC2017\"
Source: "{#projpath}\{#reponame}\Plug-Ins\Windows\CC2017\{#pluginname}\*"; \
DestDir: "{sd}\Program Files\Adobe\Adobe InDesign CC 2017\Plug-Ins\{#pluginname}"; \
Flags: ignoreversion recursesubdirs createallsubdirs replacesameversion; \
Check: MyDirCheck(ExpandConstant('{sd}\Program Files\Adobe\Adobe InDesign CC 2017'))
#endif
I know it isn't checking correctly because the file size is much smaller when I add the ifexist directives. The Inno Setup docs mention "files" but not folders so I'm suspicious that it might not support checking folders.
What is wrong with the syntax?
I'm using Inno Setup 6.0.2 on Mac 10.13.6
There are two options:
Use skipifsourcedoesntexist flag:
[Files]
Source: "folder\*"; DestDir: "{app}"; Flags: skipifsourcedoesntexist
Use #if preprocessor directive along with DirExists preprocessor function:
[Files]
#if DirExists("folder")
Source: "folder\*"; DestDir: "{app}"
#endif
I would like to instruct Inno Setup to install a certain external file only if does exist.
Like so:
Source: "d:\sources\SomeDLL.dll"; DestDir: {app}; \
Flags: external regserver uninsneveruninstall ignoreversion
However, I did not find a flag that would instruct Inno Setup to skip this line / file if d:\sources\SomeDLL.dll does not exist.
Is this possible?
Thank you!
Use the skipifsourcedoesntexist flag:
This flag instructs the compiler -- or Setup, if the external flag is also used -- to silently skip over the entry if the source file does not exist, instead of displaying an error message.
Try this flag:
onlyifdestfileexists
Only install the file if a file of the same name already exists on the user's system. This flag may be useful if your installation is a patch to an existing installation, and you don't want files to be installed that the user didn't already have.
http://www.jrsoftware.org/ishelp/index.php?topic=filessection