Reenan
22nd December 2009 20:47 UTC
Make uninstaller get a path from registry
Well, I'm making a installer for an app (thanks, Captain Obvious...)
But it installs file on one dir and on another dir, that I've got during installation, reading the registry and setting to a var.
now, when I want to uninstall, I tried the same way: read reg, set a var and delete the file from the dir, set on the var.
but uninstaller don't delete it, it just ignore the file.
what I'm doing wrong?
One more thing: when I read the reg during install, how can I make the installer send a message if it don't find anything? Like: I've made the installer read a install path of some app, but the app isn't installed on user's system. what I need to do to the installer send a message to user saying something like "the app isn't installed and additional files will be ignored"?
redxii
22nd December 2009 22:04 UTC
Can I see a code example of what you are trying to do, and where the different dirs are. $INSTDIR in an uninstaller is wherever the uninstaller resides.
As for the other.. you should read a registry entry or file from that program.
ClearErrors
ReadRegStr $R0 <some registry key set by another program>
IfErrors 0 +2
MessageBox MB_OK|MB_ICONINFORMATION "the app isn't installed and additional files will be ignored"
<continue>
Reenan
22nd December 2009 23:07 UTC
Here is my entire script:
; Script generated with the Venis Install Wizard
; Define your application name
!define APPNAME "CD Art Display"
!define APPNAMEANDVERSION "CD Art Display 2.0.1"
; Main Install settings
Name "${APPNAMEANDVERSION}"
InstallDir "$PROGRAMFILES\CD Art Display"
InstallDirRegKey HKLM "Software\${APPNAME}" ""
OutFile "C:\cad201extra.exe"
; Use compression
SetCompressor LZMA
; Modern interface settings
!include "MUI.nsh"
!define MUI_ABORTWARNING
!define MUI_FINISHPAGE_RUN "$INSTDIR\CAD.exe"
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
; Set languages (first is default language)
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_RESERVEFILE_LANGDLL
InstType Full
InstType "CAD Only"
InstType /NOCUSTOM
Section "CD Art Display" Section1
SectionIn 1 2 RO
SetDetailsPrint textonly
DetailPrint "Installing CD Art Display..."
SetDetailsPrint listonly
; Set Section properties
SetOverwrite on
; Set Section Files and Shortcuts
SetOutPath "$INSTDIR\"
File "cad201.exe"
ExecWait '"$INSTDIR\cad201.exe" /VERYSILENT /DIR="$INSTDIR" /NOICONS'
Delete "cad201.exe"
SectionEnd
Section "Winamp Plugin" Section2
MessageBox MB_OK "Make sure that Winamp is CLOSED."
SectionIn 1
ReadRegStr $0 HKCU Software\Winamp ""
DetailPrint "Winamp is installed at: $0"
SetOutPath "$0\Plugins"
File "gen_CADStarter.Plugin.dll"
File "CADStarter.dll"
SectionEnd
Section -FinishSection
SectionIn 1 2
WriteRegStr HKLM "Software\${APPNAME}" "" "$INSTDIR"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayName" "${APPNAME}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "UninstallString" "$INSTDIR\uninstall.exe"
WriteUninstaller "$INSTDIR\delete_cad.exe"
SectionEnd
; Modern install component descriptions
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${Section1} "CD Art Display Main Files - Required!"
!insertmacro MUI_DESCRIPTION_TEXT ${Section2} "Winamp plugin for CAD - useful for Winamp Users"
!insertmacro MUI_FUNCTION_DESCRIPTION_END
;Uninstall section
Section Uninstall
SectionIn 1 2
ExecWait '"$INSTDIR\unins000.exe" /VERYSILENT'
;Remove from registry...
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}"
DeleteRegKey HKLM "SOFTWARE\${APPNAME}"
; Delete self
Delete "$INSTDIR\delete_cad.exe"
; Clean up CD Art Display
Delete "$INSTDIR\cad201.exe"
ReadRegStr $0 HKCU Software\Winamp ""
DetailPrint "Winamp is installed at: $0"
Delete "$0\gen_CADStarter.Plugin.dll"
Delete "$0\CADStarter.dll"
; Remove remaining directories
RMDir "$INSTDIR\"
SectionEnd
BrandingText "CD Art Display - Extra edition by ~reenan"
; eof
As you can see, I'm trying to make a CD Art Display with Winamp Plugin Embedded. I've figured that I could bundle the installer of CAD inside a new installer, and this makes everything a lot easier.
But when uninstalling... it gets the problem.
About the other thing that I've asked, can you (or somebody) explain it a little more?
And, to not make another topic, how can I make a script that adds EVERYTHING from a folder? I can simple use:
File "*.*"
?
redxii
23rd December 2009 20:09 UTC
I can't make it work either, but it'd be better to grab the Winamp path from HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\winamp.exe (Path) because HKCU key would only work on the user that installed Winamp.
And yes you can use wildcards.
Reenan
24th December 2009 00:55 UTC
I've tried wildcards, and appears that it didn't worked. :P
And thanks for the tip of the regkey, I really need that it work on every situation.
I'm trying to solve the problem this way:
ReadRegStr $0 HKCU Software\Winamp ""
DetailPrint "Winamp is installed at: $0"
!define WINAMPDIR "$0"
Delete "${WINAMPDIR}\gen_CADStarter.Plugin.dll"
Delete "${WINAMPDIR}\CADStarter.dll"
redxii
24th December 2009 08:08 UTC
Defines are supposed to be compile-time. The two delete commands will just end up back as 'Delete "$0\..."'.
Only other way I can think of is to create a batch file and insert the paths into that. It'd look something like this:
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\winamp.exe" "Path"
DetailPrint "Winamp is installed at: $0"
FileOpen $9 "$PLUGINSDIR\delplugins.bat" w
FileWrite $9 "del $0\Plugins\gen_CADStarter.Plugin.dll"
FileWrite $9 "del $0\Plugins\CADStarter.dll"
FileWrite $9 "exit"
FileClose $9
From:
http://nsis.sourceforge.net/Write_text_to_a_file
I'm not familiar with executing batch files, look here:
http://forums.winamp.com/showthread....61#post2054461
As for the File command, see if this helps any:
http://nsis.sourceforge.net/Docs/Chapter4.html 4.9.1.5 File
Reenan
25th December 2009 01:17 UTC
I had that idea too, will try it later. Thanks!
If I need more help, I'll come here to say :)