Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   NSIS Discussion (http://forums.winamp.com/forumdisplay.php?f=65)
-   -   Find if a previous soft is installed (http://forums.winamp.com/showthread.php?t=268042)

ichyban 19th March 2007 11:47

Find if a previous soft is installed
 
Hi, i am a newbie on NSIS and also on this forum. The script that i wrote installs a soft in a directory that i choose. Is there a way to find out if the soft is already installed on the computer, before i get to the component page and how to calculate the space required for installation.

Hope i will hear from you soon,
Thanks

Red Wine 19th March 2007 12:23

How about InstallDirRegKey? See NSIS manual,

http://nsis.sourceforge.net/Docs/Chapter4.html#4.8.1.22

Required space calculated automatically by the installer on components page and on directory page.

ichyban 19th March 2007 13:48

thanks i will try

ichyban 19th March 2007 14:13

i have done this:

!define company "Home"
!define prodname "TestApp"
!define regkey "Software\${company}\${prodname}"

Section
InstallDirRegKey HKLM "${regkey}"
SectionEnd

Error: command InstallDirRegKey not valid in Section

Comm@nder21 19th March 2007 14:24

then use InstallDirRegKey outside a section!

Red Wine 19th March 2007 14:30

As described in manual this is an installer attribute, so you need to add it like this e.g.

Name "my app"
OutFile "myapp.exe"
InstallDirRegKey HKLM "Software\NSIS" ""

ichyban 20th March 2007 12:01

ok i have done this:
Name "my app"
OutFile "myapp.exe"
InstallDirRegKey HKLM "${regkey}" ""

i tested the installer but what i should do so when i try to use the installer will warn me that i have the soft already installed

Red Wine 20th March 2007 12:48

Provided that ${regkey} is defined properly, installer finds automatically any previous installation.
If you want to pop up a warning or set up another action regarding to that previous installation then,
Function .onInit
ClearErrors
ReadRegStr $0 HKLM "${regkey}" ""
IfErrors done
MessageBox MB_OK "Previous installation detected here $0"
# code here
done:
ClearErrors
# other code here
FunctionEnd

ichyban 20th March 2007 13:21

1 Attachment(s)
i have attached the source...please take a look...i did what you told me to do but has no effect

thanks

Red Wine 20th March 2007 13:36

Hopefully this minimal out of script will help you,
code:
!define uninstaller "uninstall.exe"
!define prodname "testapl"
!define company "Home"
!define regkey "Software\${company}\${prodname}"

Outfile 'test.exe'
InstallDir '$PROGRAMFILES\${prodname}'
InstallDirRegKey HKLM "${regkey}" ""
AutoCloseWindow false
ShowInstDetails show

!include "mui.nsh"

!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_LANGUAGE "English"

Function .onInit
ClearErrors
ReadRegStr $0 HKLM "${regkey}" ""
IfErrors done
MessageBox MB_OK "Previous installation detected here $0" IDOK

done:
ClearErrors
FunctionEnd

Section
SetOutPath "$INSTDIR"
WriteUninstaller "${uninstaller}"
WriteRegStr HKLM "${regkey}" "" "$INSTDIR"
SectionEnd

Section "Uninstall"
Delete "$INSTDIR\${uninstaller}"
RMDIR "$INSTDIR"
DeleteRegKey HKLM "${regkey}"
SectionEnd


ichyban 20th March 2007 14:14

It works...thanks a lot


All times are GMT. The time now is 05:11.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.