Problem with the $INSTDIR and registry
I'm currently makin a mappack for CS.
I need to know the exact path of the cstrike directory.
So I've coded it that way :
;DIF.nsiI had to disable the directory selection page, because when it was enabled, the detected path (that works) wasn't displayed in the editbox...and the browse function was of no use, because whatever directory you choosed, the mappack installed in the righ directory, the $INSTDIR\cstrike.
;
;Install script by Jubijub
;
;
;
;init numero de version
!define VER_MAJOR 1
!define VER_MINOR 1
;Nom de l'installer
Name "DIF-Mappack v${VER_MAJOR}.${VER_MINOR}"
Caption "-=[D.I.F]=- Mappack v${VER_MAJOR}.${VER_MINOR} by Jubijub"
;Nom du fichier
OutFile "DIF-mappack_v${VER_MAJOR}.${VER_MINOR}.exe"
;parametres generaux
Icon main.ico
MiscButtonText "Retour" "Suivant" "Annuler" "Fermer"
;Composants
EnabledBitmap d:\test\three-check.bmp
DisabledBitmap d:\test\three-nocheck.bmp
AutoCloseWindow false
ShowInstDetails show
ShowUninstDetails show
SetCompress auto
SetDatablockOptimize on
CRCCheck on
BGGradient 000000 e21c00 FFFFFF
InstallColors e21c00 000000
InstProgressFlags smooth colored
SetOverwrite ifnewer
DirShow hide
DirText ""
;detection rep half-life
section ""
ReadRegStr $INSTDIR HKLM "software\Valve\Half-Life" InstallPath
SectionEnd
;licence
LicenseText "Vous devez accepter ce qui suit avant de continuer:"
LicenseData license.txt
;caption
ComponentText "Ceci installera le pack -=[D.I.F]=- dans le repertoire de Counter-strike"
DetailsButtonText "Details"
CompletedText "Operation terminée avec succès"
InstallDir $INSTDIR
InstallDirRegKey HKLM SOFTWARE\DIF "Install_Dir"
;INSTALL
; Section principale
Section "Maps (requis)"
SetOutPath $INSTDIR\cstrike
file d:\test\*.wad
SetOutPath $INSTDIR\cstrike\maps
file d:\test\maps\*.*
;SetOutPath $INSTDIR\cstrike\sound
;SetOutPath $INSTDIR\cstrike\gfx
WriteRegStr HKLM SOFTWARE\DIF "Install_Dir" "$INSTDIR\cstrike"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DIF" "DisplayName" "DIF Mappack (remove only)"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DIF" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteUninstaller "uninstall.exe"
SectionEnd
; section bonus
Section "Bonus sons kevlar+NV"
SetOutPath $INSTDIR\cstrike\sound\items
file d:\test\sounds\items\*.wav
SectionEnd
; section uninstall
Section "Uninstall"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DIF"
DeleteRegKey HKLM SOFTWARE\DIF
Delete $INSTDIR\cstrike\porno.wad
Delete $INSTDIR\cstrike\cs_thunder.wad
Delete $INSTDIR\cstrike\maps\cs_beirut.bsp
Delete $INSTDIR\cstrike\maps\cs_beirut.txt
Delete $INSTDIR\cstrike\maps\cs_docks_v1.bsp
Delete $INSTDIR\cstrike\maps\cs_docks_v1.txt
Delete $INSTDIR\cstrike\maps\cs_thunder.bsp
Delete $INSTDIR\cstrike\maps\cs_vineyard.bsp
Delete $INSTDIR\cstrike\maps\cs_vineyard.txt
Delete $INSTDIR\cstrike\maps\de_dust4ever.bsp
Delete $INSTDIR\cstrike\maps\de_dust4ever.txt
Delete $INSTDIR\cstrike\maps\de_kaktus.bsp
Delete $INSTDIR\cstrike\maps\de_kaktus.txt
Delete $INSTDIR\cstrike\maps\de_rotterdam.bsp
Delete $INSTDIR\cstrike\maps\de_rotterdam.txt
Delete $INSTDIR\cstrike\maps\pa_kruncinator(fr).txt
Delete $INSTDIR\cstrike\maps\pa_krunchinator.bsp
Delete $INSTDIR\cstrike\maps\pa_krunchinator.txt
Delete $INSTDIR\cstrike\maps\pa_krunchinator_readme.txt
Delete $INSTDIR\cstrike\maps\pa_krunchinator_readme(fr).txt
Delete $INSTDIR\cstrike\sound\items\equip_nvg.wav
Delete $INSTDIR\cstrike\sound\items\kevlar.wav
Delete $INSTDIR\cstrike\sound\items\nvg_off.wav
Delete $INSTDIR\uninstall.exe
Delete $INSTDIR\cstrike\uninstall.exe
SectionEnd
; eof
I would like to turn this feature back on, so that people could be able to check if the detected path is right or not