Why my uninstaller is not working properly in nsis? - nsis

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...

Related

NSIS : Delete files from Hidden folder (from start menu)

I have written code script for uninstall of my application, somehow uninstall.exe is getting deleted. so script is not able to uninstall product . Now I want to write a script to delete folders directly from directory,
From
1. Installation Directory
2. Start Menu
I can delete it from Installation Directory , but as start Menu is inside ProgramData , and Program data folder is hidden. I am not able to delete it by nsis, please suggest the efficient approach.
Description :
-When I install new version of application ,it'll automatically uninstall previous installed location (just running uninstall.exe).
-Sometimes some how uninstall.exe get deleted , so while installing new version , user needs to delete application mannually from installed location and from StartMenu (C:\ProgramData\Microsoft\Windows\Start Menu\Programs\$application)
I am thinking to remove these directoryy from nsis script.
But C:\ProgramData is hidden so i am not able to delete it by script,
Is there any possible way.

Path to uninstaller in Inno Setup

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.

NSIS: Writing to registry (not HKLM)

Please help me: I want to write some data to registry. You might say "Wait, wait, this is one of the basic features in NSIS!", but, I want to write to the app registry (HKCU, not HKLM). The main purpose is: when the installer installs my product it also installs my update manager. I just want to write the product installation directory to the Updater branch, so it can further fetch the update package and install it to the product directory.
If you have RequestExecutionLevel admin in your script and you are installing to $ProgramFiles then you are doing a machine/all users install and the installer should not write to HKCU. Your application must initialize its entries in HKCU and AppData the first time the user runs it. You cannot do it in the installer because UAC might run the installer as the "wrong" user.
If you have RequestExecutionLevel user in your script then you are doing a single user install and the installer should only write to HKCU and [Local]AppData.

Prevent additional uninstaller uninstall everything

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.

NSIS installer remembering previous install directory

I've got a problem where the NSIS installer is remembering the previous install location of the product I want to install after the previous version of the product is installed.
I want to prevent this behavior ... so that the installer uses the default directory I specify in the script.
Found the solution ... needed to remove InstallDirRegKey from my script.
http://nsis.sourceforge.net/InstallDir_doesn%27t_work

Resources