During install, the installer creates a backup directory with a timestamp added to make it unique if installer is started multiple times.
During uninstall I need to process some files (not placed by [Files] and [Dir] section) to be restored in the usUninstall or usPostUninstall. These files are placed in sub-directories in the backup directory.
For this, I need my location where the uninstaller is started so I can restore the files.
I found and tried the GetCurrentDir function. But during uninstall the GetCurrentDir function returns the location c:\WINDOWS\system32.
I tested it also during install, but in that case the GetCurrentDir function returns the location where the installer is started.
How to get the proper location from where the uninstall is started?
The {uninstallexe} constant resolves to a path to the uninstaller.
If you combine that with ExtractFilePath, you get a path to the uninstaller folder:
ExtractFilePath(ExpandConstant('{uninstallexe}'))
Though actually, the path will typically be the installation path. So you can use {app} constant directly.
Do not use GetCurrentDir! It returns the current working directory. What does not have to be the path to the installer.
Use {src} constant.
Related
I run a lot of node projects and often have binaries located in:
.\node_modules\.bin
...relative to the projects folder. I'd like to be able to have PATH always include these directories, if they exist. I don't want to include other directories, just the one relative to the current directory. I'm familiar with
Add-PathVariable from PSCX and other Powershell basics, but how do I include a folder relative to the current dir in PATH?
Edit: as mentioned in the question, already, I expect the path to stay updated as the directory changes. This is not simply asking about how to use pwd.
You can use a relative path in Env:PATH and the binaries found will update dynamically:
Eg:
$env:PATH += ';.\node_modules\.bin'
Or with the PowerShell Community Extensions (PSCX):
Add-PathVariable '.\node_modules\.bin'
Unlike using $(pwd) the . is not immediately resolved to an absolute path, so PATH is always relative to the current working directory.
Testing this:
$ which uuid
C:\Users\username\Documents\myapp\node_modules\.bin\uuid.cmd
Then changing directory, uuid now refers to a program in a different dir:
$ cd ..\blog\
$ which uuid
C:\Users\username\Documents\blog\node_modules\.bin\uuid.cmd
It's also possible to persistently change PATH in the user or system environment:
[Environment]::SetEnvironmentVariable(($env:PATH + ';.'), 'User')
or
[Environment]::SetEnvironmentVariable(($env:PATH + ';.'), 'Machine')
Security note: when entering a command Windows will automatically search all directories in $env:PATH for files with one of the extensions listed in $env:PATHEXT and execute the first match it finds. Depending on where exactly in the search path you placed . that may even supersede system executables.
You may want to take a look at how to use package installed locally in node_modules for alternative approaches.
I have an innosetup installer which installs a plugin into the root directory of an application which is also installed with innosetup. After installing my plugin into this dir there are multiple uninst* files:
app/
unins000.exe (the apps uninstaller)
unins000.dat
unins001.exe (another plugin's uninstaller)
unins001.dat
unins002.exe (my plugin's uninstaller)
unins002.dat
Problem is running unins002.exe uninstalls all files in this folder, I need only the files created by my plugin to be uninstalled.
How can I achieve this?
In the [setup] section you need to provide a different (or non-default) AppId value.
When the installer runs and the same the AppId exists for an existing uninstall manifest then Inno will merge them.
Fixed. It was due to a misconfigured UninstallDelete section.
I have written a nsis script in which i need to prompt the user where there was previous installation and uninstall the previous version if user select the same folder as previous version.It is working fine.But suppose user choose different directory than the uninstall.exe is giving problem.
Ex-suppose user install version 1.2 in folder a and then agian version 1.2 in folder B .
Than in every case the uninstall .exe is pointing to folderb not folder a.How can i solve this issue
In the uninstaller, $instdir is just the directory the uninstaller is in so the uninstaller itself should not care.
You say you are prompting the user, so you already know the location of the old install so all you have to do is to invoke the uninstaller with the special parameter so it knows where to uninstall from...
I have a DLL that I am calling from Inno setup script, dll is looking to load some file from the path where executable is located.
In my case when I execute the setup, temporary executable is exported in temp folder is-xxxxx
BTW, {tmp} is not the right one. It is another tmp folder but not the one that temporary setup.
I need to know that in inno setup is there a constant to represent that folder.
Thanks.
Your DLL can determine which path it's been extracted to and it can also determine the path of the temporary executable. The way you do it depends on the language your DLL is written in.
But the Key Windows API call is GetModuleFileName
If your DLL was written in Delphi you could use the following to get the path of Setup.exe
ExtractFilePath(ParamStr(0))
How about this
path := ExpandConstant('{src}');
I use Inno Setup for my product's installer/uninstaller. My software has auto-update capabilities during which time it may not only change existing binaries but may also add new ones. These are additional product files that are placed into the product's installation directory - not data files.
The Inno Setup uninstaller only knows to uninstall files by name that it originally put there at install time. Since an automatic update doesn't change either the unins000.exe or unins000.dat files that make up the uninstaller, what would be the appropriate way to delete these new product files at uninstall time?
The easiest way I see is to have a batch file in your program dir that deletes all files that were added after the installation and is executed on uninstall:
[UninstallRun]
Filename: cleanup.cmd; WorkingDir: {app}; Flags: shellexec runminimized
UninstallRun commands are executed as the first step of the uninstallation, so this should work fine. If you are bothered by the idea of running a batch script, you can easily create your own cleanup.exe that deletes the files.
When you perform the auto update, you must also update the cleanup file, so that it includes all files that were added with the current update.