Renaming/replacing ShortCut During Inno Setup Installation - inno-setup

The [InstallDelete] Section enables files to be deleted but does not enable icons to be deleted (the only Type supported is files, I was hoping it also supported icons).
I need to change the shortcuts that are associated the programs being installed. I can add a new shortcut (e.g. 'Maintenance') by adding the appropriate parameters to the [Icons] section but have not found a way of removing the old shortcut (e.g. 'Repair').
Has anyone got any ideas how this can be acheived without delving into the Registry - I am familiar (but certainly not an expert) in the use of Pascal Scripting.

"Icon" aka Shortcut is just .lnk file placed somewhere - e.g. on your Desktop - pointing to other file - e.g. Program.exe - in {app} directory.
If you create such "icon" in [Icons] section it is automatically deleted during uninstall (unless the uninsneveruninstall Flag is set).
If you have some "icon" which you want to delete then simply delete the .lnk file from destination folder (e.g. Desktop).
You can do that in [InstallDelete] or [UninstallDelete] or programatically in [Code] section:
[InstallDelete]
Type: files; Name: "{commondesktop}\My Program.lnk"
where "{commondesktop}\My Program.lnk" is the path\name of the icon (actually the name of the .lnk file) to delete.

Related

How to support thousands of files using Inno Setup?

I'm using Inno Setup to write an installer for an application based on Node.js. Then our node application (including modules) consists of almost 4,000 files. The installer needs to copy all of these files, as well as remove them during uninstallation.
I've already written this to use a ZIP file which gets extracted during installation, and recursively delete files during the uninstall. But I would have to write a tremendous amount of code to be able to properly handle file copy/replace/delete operations, while I could register them in my Inno Setup script and let the installer do all that work (as it's designed to do). The problem with that is I'm not about to manually write almost 4k lines of code (and manage them when frequent additions are made) for each file. I could write a small app to iterate through the files and write ISS script, but that's another project I'm not about to start.
Is there a way to not only add, but manage groups of files in bulk in recursive folders? Perhaps a custom IDE meant for this?
There are many way to add all files to inno setup:
You can use Flags: recursesubdirs;
For example:
[Files]
Source: "C:\Source Folder\*"; DestDir: "{app}"; Flags: recursesubdirs
You can use inno setup quick start pack
You can install Only Istool
TO put files in Istool open Files and directory section in Istool Drag and drop all (Select Thousand of files or Folder if any with Ctrl+A)
Thousand Of files in the Files and directory section of Istool and save.
PS: If you use Istool then save the Documents and open with inno setup.
I personaly Use Istool.
Thanks

Could I control what to be uninstalled when uninstall one application in inno setup?

One quick question about inno-setup: Can I customize which files to be removed by uninstaller? As I know, the uninstaller always uninstall all the files created by installer. If the answer is Yes, what should I do for that?
My case is: After I install my application, directory "{pf}\myapp\" include some dlls, two executable files, and there created two desktop icons and uninstallers for each executable file. What I expect is user can uninstall each executable file, rather than all the files; and if it's the only executable file left, uninstaller will remove all the files.
Thanks in advance.
If you want separate uninstallers, you have to write separate installers. The general rule is you have to write a separate installer per application.
This said, you can have any number of shared files, which can be dll's, executables, etc. that are shared between distinct applications.
Windows have well defined procedures to keep track of shared files, with a reference count. The reference count is incremented by the installer and decremented by the uninstaller. The files are removed from the system only if the reference count reach 0 during uninstallation.
You use the sharedfile flag to instruct the installer the file is shared. The MyLib.dll file is shared in the following example:
[Files]
Source: "MyProg.exe"; DestDir: "{app}"
Source: "MyProg.chm"; DestDir: "{app}"
Source: "MyLib.dll"; DestDir: "{sys}"; Flags: sharedfile
Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme
From the documentation (emphasis mine):
sharedfile
Specifies that the file is shared among multiple applications, and should only be removed at uninstall time if no other applications are using it. Most files installed to the Windows System directory should use this flag, including .OCX, .BPL, and .DPL files.
Windows' standard shared file reference-counting mechanism (located in the registry under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SharedDLLs) is used to keep track of how many applications depend on the file. Each time the file is installed, the reference count for the file is incremented. (This happens regardless of whether the installer actually replaces the file on disk.) When an application using the file is uninstalled, the reference count is decremented. If the count reaches zero, the file is deleted (with the user's confirmation, unless the uninsnosharedfileprompt flag is also specified).

three components in three user defined locations

I saw this excellent article: Inno Setup - Correct use of [Types], [Components] and [Tasks] on components and types.
I currently have three separate setup.exe projects (iss) to install:
The program executable (default to: C:\ProgramFiles/ ) i.e. {pf}
a setup of js/css/html (default to: c:\wwwroot\sherlock
a setup to install image files (jpg/png) files (default to: c:\wwwroot\toby
I want the user it be able to redirect the default locations for each of these three "components" (i.e. perhaps his /wwwroot is on the G drive, or something like that. I don't see anyway in the Source: command other than to send this to {app}
Source: "Z:\EGPL Librarian Releases\Sample Installation\wwwroot\Sherlock\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Question: can this be done with components and types as the above article?
Should I rather create an installer of installer programs and keep the three separate setups? (And can you show me an example of an installer of installer programs?)
I am looking for a simple solution, since I have other work to do.
See this page. Note that it was written for an older version of Inno, but it should be easy enough to adapt.
Components/Tasks are for optional things. If your items are not optional then there's not much point in using them.
As for whether to make a single installer or an installer of installers -- the main question there is what you want to happen at uninstall time. If you want the user to be able to uninstall each part separately then you must create separate install scripts with unique AppIds (and then optionally make an installer of installers for them). If you want them to always be uninstalled together then you can make a single script.

How can you harvest files for Inno Setup

I am trying to find a tool similar to heat for WiX that will allow me to harvest file and folder entries for Inno Setup. Is there anything available?
Edit: Heat is used to harvest installation artifacts (files, folders, registry entries, etc) from a machine and generate a WiX source file. I know Wise for Windows Installer had a wild card option that performed a similar function. I have not found anything similar for Inno Setup.
I am trying to include hundreds of files (dozens of folders) of sample projects and data to go with our application installation. These will change between releases and I was hoping to automate this portion of the installation authoring.
You can include an entire directory tree via wildcards and recursion, eg:
[Files]
Source: somewhere\root\*; DestDir: {app}\Data; Flags: recursesubdirs
(If you want to include empty directories as well, add the createallsubdirs flag too.)
There is no direct equivalent for registry entries, but eg. ISTool can convert a .reg file into the corresponding [Registry] entries.

How to remove a desktop shortcut by Innosetup

How can I remove a desktop shortcut by Innosetup? It's created by previous version and not needed anymore. I tried delete it in [InstallDelete]
[InstallDelete]
Type: files; Name: {userdesktop}\Shortcut Name
and delete the file in "ssInstall" of CurStepChanged event handler
DeleteFile(ExpandConstant('{userdesktop}\Shortcut Name'));
But they don't work. Any suggestion is appreciated!
Either option will work, but there are a couple of considerations.
1) You'll either need to use {userdesktop} or {commondesktop} depending on whether the shortcut was installed for a specific user or for all users.
2) You'll need to make sure to add the .lnk extension to the shortcut name.
So this will probably work:
DeleteFile(ExpandConstant('{userdesktop}\Shortcut Name.lnk'));
DeleteFile(ExpandConstant('{commondesktop}\Shortcut Name.lnk'));
or
[InstallDelete]
Type: files; Name: "{userdesktop}\Shortcut Name.lnk"
Type: files; Name: "{commondesktop}\Shortcut Name.lnk"

Resources