![]() |
#1 |
Junior Member
Join Date: Jun 2019
Posts: 12
|
UninstallString works QuietUninstallString not
I have a script has code to remove an old version that works:
ReadRegStr $PreviousUninstaller HKLM ${DSS_REG_UNINSTALL_PATH} "UninstallString" ExecWait '"$PreviousUninstaller" /S _?=$INSTDIR' If I instead code: ReadRegStr $PreviousUninstaller HKLM ${DSS_REG_UNINSTALL_PATH} "QuietUninstallString" ExecWait '"$PreviousUninstaller" _?=$INSTDIR' That DOES NOT work. Here's how I'm setting them: WriteRegStr HKLM "${DSS_REG_UNINSTALL_PATH}" "UninstallString" "$INSTDIR\${DSS_UNINSTALL_FILE}.exe" WriteRegStr HKLM "${DSS_REG_UNINSTALL_PATH}" "QuietUninstallString" "$INSTDIR\${DSS_UNINSTALL_FILE}.exe /S" I assume (ha!) that I'm doing something wrong - but what? Thanks David |
![]() |
![]() |
![]() |
#2 | |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,504
|
Wrong quotes.
Double quotes are for paths, not the entire command. Quote:
The compiler removes the outer set of quotes so your UninstallString value is not actually quoted and that could be problematic if the path contains a space. You get the classic c:\Program Files\App.exe vs c:\Program.exe problem. When executing you should not add quotes around the variable because it should already be quoted, ExecWait '$PreviousUninstaller _?=$INSTDIR' but $INSTDIR is not really correct here, you should really extract the old path from $PreviousUninstaller. IntOp $PostCount $PostCount + 1 |
|
![]() |
![]() |
![]() |
#3 |
Junior Member
Join Date: Jun 2019
Posts: 12
|
Do you have a code clip you can share to do that path extraction?
And if possible please could you confirm that this is correct? code: Thanks David |
![]() |
![]() |
![]() |
#4 | |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,504
|
I'm sure one of the standard include files can do it or grab PathRemoveArgsAndQuotes from https://gist.github.com/sredna/45e51...44e523f3c31fc1
Quote:
IntOp $PostCount $PostCount + 1 |
|
![]() |
![]() |
![]() |
#5 |
Junior Member
Join Date: Jun 2019
Posts: 12
|
Just to confirm is this what I need near the beginning:
!include "UtilBonus.nsh" # Add Path extraction macro !insertmacro PathRemoveArgsAndQuotes Then the code you've kindly shown ... Is that right? David |
![]() |
![]() |
![]() |
#6 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,504
|
Or just copy that single function, you don't need the entire header.
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#7 |
Junior Member
Join Date: Jun 2019
Posts: 12
|
Odd I included the header and tried to compile my script and got this:
CRCCheck: On Error: can't change compressor after data already got compressed or header already changed! Error in script "D:\Users\amonra\Documents\GitHub\DSS\Installers \DeepSkyStackerInstaller32.nsi" on line 50 -- aborting creation process I don't understand that at all! |
![]() |
![]() |
![]() |
#8 |
Junior Member
Join Date: Jun 2019
Posts: 12
|
I just copied that into a fifle PathRemove.nsh which I included.
I that had: # Uninstall previous version silently ReadRegStr $PreviousUninstaller HKLM ${DSS_REG_UNINSTALL_PATH} "UninstallString" ${If} PreviousUninstaller != "" ${PathRemoveArgsAndQuotes} $0 $PreviousUninstaller ExecWait '$PreviousUninstaller /S _?=$0' ${EndIf} and got this: ReadRegStr $PreviousUninstaller HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\DeepSkyStacker32\UninstallString !insertmacro: _If !insertmacro: end of _If !insertmacro: PathRemoveArgsAndQuotes warning 6000: unknown variable/constant "{in}" detected, ignoring (macro:PathRemoveArgsAndQuotes:1) Push: ${in} Call "PathRemoveArgsAndQuotes" Pop: $PreviousUninstaller !insertmacro: end of PathRemoveArgsAndQuotes ExecWait: "$PreviousUninstaller /S _?=$0" (->) !insertmacro: _EndIf !insertmacro: end of _EndIf What did I do wrong? David And then when I ran the installer, I saw this: Execute: ${in} /S _?= which surely isn't right!!! |
![]() |
![]() |
![]() |
#9 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,504
|
1) "change compressor after data already got compressed" means that the order of things in your .NSI is wrong. You must set the Compressor and Unicode attributes at the top of the .NSI before !includes and functions.
2) ${in} is a bug, I changed the code slightly on Github after I wrote it. I have fixed it on Github now, try again (sorry). IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#10 |
Junior Member
Join Date: Jun 2019
Posts: 12
|
My code reads thus:
code: When I run the installer and if there is no previous install (No uninstall string) I see: code: when I run the installer. Whereas if there is a previous install I see; code: I thought your parser returned just the path (without the .exe). AFAICT it just returns the string it was provided which doesn't seem right? David |
![]() |
![]() |
![]() |
#11 | |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,504
|
1) ${If} PreviousUninstaller != "" should cover this but there is a missing $, it should be $PreviousUninstaller != "".
2) Yes, my fault again I'm afraid, I just was not thinking about things correctly. You do want just the path without the filename. You have two options. A) Just add "\..": Quote:
or B) Remove the filename. FileFunc.nsh has a GetParent or you can use https://nsis.sourceforge.io/Get_parent_directory#. IntOp $PostCount $PostCount + 1 |
|
![]() |
![]() |
![]() |
#12 |
Junior Member
Join Date: Jun 2019
Posts: 12
|
code: Results in the following if the product is already installed: code: Which I think is correct? Should _? be quoted or not? And no action if the product wasn't installed. Dave |
![]() |
![]() |
![]() |
#13 | |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,504
|
_?=
Quote:
IntOp $PostCount $PostCount + 1 |
|
![]() |
![]() |
![]() |
#14 |
Junior Member
Join Date: Jun 2019
Posts: 12
|
Argghh! That breaks big time if the Uninstall String isn't quoted (yes I know that isn't right but our first install scipts did it wrong!) ...
code: Is there an easy way to fix that up - I'm really struggling with the string functions here! Dave |
![]() |
![]() |
![]() |
#15 |
Junior Member
Join Date: Jun 2019
Posts: 12
|
OK I've now got it working correctly - this is the final code:
code: This results in the following when the installer is run: code: With _? paramter specifically NOT being quoted! Wish that hadn't been quite such a struggle! Thanks, David |
![]() |
![]() |
![]() |
#16 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,504
|
And now we have https://nsis.sourceforge.io/Auto-uni...installing_new
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|