hye guys, problom with installation, please take a look!
hey guys!
i'm new to NSIS and this is my first installation made, it's working quite ok, however i do have some issues that i've failed to over-come no matter how hard i've tried!!!
______-
- the main problem is situated in the uninstalling field:
ReadRegStr $RestartInstaller HKCU "Software\SKs\USDownloader" "RestartInstaller"
${If} $RestartInstaller = "1"
ExecShell "open" "$EXEPATH\$EXEFILE"
${EndIf}
this code i've wrote in order to read a certain key which is written to the registry in here:
WriteRegStr HKCU "Software\SKs\USDownloader" "RestartInstaller" "1"
and once read to check if it's value equals to '1' then to start the installer again!- That doesn't do it!!!
- my second issue is that the function files copy seems to create files which arn't already existing and even if i try to skip the function using iffileexists function it just doesn't work!
${If} $SAVEDFILE = 1
CreateDirectory "$INSTDIR"
CopyFiles /SILENT /FILESONLY "$TEMP\USDownloader.ini" "$INSTDIR\USDownloader.ini" 10
Delete "$TEMP\USDownloader.ini"
IfFileExists "$TEMP\USDownloader.lst" 0 +3
CopyFiles/SILENT /FILESONLY "$TEMP\USDownloader.lst" "$INSTDIR\USDownloader.lst" 10
Delete "$TEMP\USDownloader.lst"
IfFileExists "$TEMP\DecryptionCheck.ini" 0 +3
CopyFiles/SILENT /FILESONLY "$TEMP\DecryptionCheck.ini" "$INSTDIR\DecryptionCheck.ini" 10
Delete "$TEMP\DecryptionCheck.ini"
IfFileExists "$TEMP\Reconnect.ini" 0 +3
CopyFiles/SILENT /FILESONLY "$TEMP\Reconnect.ini" "$INSTDIR\Reconnect.ini" 10
Delete "$TEMP\Reconnect.ini"
${EndIf}
if it might help here is my entire code for the installatoin: (Any suggestions will be happily heard!)
:
because this will make your installer start faster.
;make it start the installer after uninstallation!
;--------------------------------
!ifdef HAVE_UPX
>!packhdr tmp.dat "upx\upx -9 tmp.dat"
>!endif
!ifdef NOCOMPRESS
SetCompress off
>!endif
;--------------------------------
;Include Modern UI
!include "LogicLib.nsh"
!include "MUI.nsh"
>;--------------------------------
;General
;Name and file
Name "USDownloader"
Caption "SK's USDownloader (v27.5)"
OutFile "SK's USDownloader.exe"
;Style
!insertmacro MUI_DEFAULT MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\orange-install-nsis.ico"
!insertmacro MUI_DEFAULT MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall-nsis.ico"
XPStyle on
;Default installation folder
InstallDir "$PROGRAMFILES\SK's\USDownloader"
;Get installation folder from registry if available
InstallDirRegKey HKCU "Software\SKs\USDownloader" ""
;Vista redirects $SMPROGRAMS to all users without this
RequestExecutionLevel admin
>;--------------------------------
;Variables
Var MUI_TEMP
Var STARTMENU_FOLDER
Var SAVEDFILE
Var RestartInstaller
>;--------------------------------
;Interface Configuration
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\orange-nsis.bmp" ; optional
!define MUI_ABORTWARNING
VIProductVersion "1.0.0.0"
VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "SK's USDownloader (v27.5)"
VIAddVersionKey /LANG=${LANG_ENGLISH} "Comments" "USDownloader compliation made by SK, fully automates download from share sites!"
VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "For The Greater Good!"
VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalTrademarks" "USDownloader is a freeware by Dimoniusis, Recompiled by Shlomi Kalfa"
VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "© Shlomi Kalfa"
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "SK's USDownloader (v27.5)"
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "27.5.2007"
>;--------------------------------
;Language Selection Dialog Settings
;Remember the installer language
!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
!define MUI_LANGDLL_REGISTRY_KEY "Software\SKs\USDownloader"
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
>;--------------------------------
;Pages
!insertmacro MUI_PAGE_LICENSE "C:\USDBCKUP\Installations\License.txt"
!insertmacro MUI_PAGE_DIRECTORY
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\SKs\USDownloader"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
!insertmacro MUI_PAGE_STARTMENU Application "$STARTMENU_FOLDER"
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_RUN "$INSTDIR\USDownloader.exe"
!define MUI_FINISHPAGE_NOREBOOTSUPPORT
!define MUI_FINISHPAGE_SHOWREADME
!define MUI_FINISHPAGE_SHOWREADME_TEXT "Setup auto-reconnector"
!define MUI_FINISHPAGE_SHOWREADME_FUNCTION StartReconnector
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
>;--------------------------------
;Languages
!insertmacro MUI_LANGUAGE "English" ;first language is the default language
!insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "German"
!insertmacro MUI_LANGUAGE "Spanish"
!insertmacro MUI_LANGUAGE "SimpChinese"
!insertmacro MUI_LANGUAGE "TradChinese"
!insertmacro MUI_LANGUAGE "Japanese"
!insertmacro MUI_LANGUAGE "Korean"
!insertmacro MUI_LANGUAGE "Italian"
!insertmacro MUI_LANGUAGE "Dutch"
!insertmacro MUI_LANGUAGE "Danish"
!insertmacro MUI_LANGUAGE "Swedish"
!insertmacro MUI_LANGUAGE "Norwegian"
!insertmacro MUI_LANGUAGE "NorwegianNynorsk"
!insertmacro MUI_LANGUAGE "Finnish"
!insertmacro MUI_LANGUAGE "Greek"
!insertmacro MUI_LANGUAGE "Russian"
!insertmacro MUI_LANGUAGE "Portuguese"
!insertmacro MUI_LANGUAGE "PortugueseBR"
!insertmacro MUI_LANGUAGE "Polish"
!insertmacro MUI_LANGUAGE "Ukrainian"
!insertmacro MUI_LANGUAGE "Czech"
!insertmacro MUI_LANGUAGE "Slovak"
!insertmacro MUI_LANGUAGE "Croatian"
!insertmacro MUI_LANGUAGE "Bulgarian"
!insertmacro MUI_LANGUAGE "Hungarian"
!insertmacro MUI_LANGUAGE "Thai"
!insertmacro MUI_LANGUAGE "Romanian"
!insertmacro MUI_LANGUAGE "Latvian"
!insertmacro MUI_LANGUAGE "Macedonian"
!insertmacro MUI_LANGUAGE "Estonian"
!insertmacro MUI_LANGUAGE "Turkish"
!insertmacro MUI_LANGUAGE "Lithuanian"
!insertmacro MUI_LANGUAGE "Catalan"
!insertmacro MUI_LANGUAGE "Slovenian"
!insertmacro MUI_LANGUAGE "Serbian"
!insertmacro MUI_LANGUAGE "SerbianLatin"
!insertmacro MUI_LANGUAGE "Arabic"
!insertmacro MUI_LANGUAGE "Farsi"
!insertmacro MUI_LANGUAGE "Hebrew"
!insertmacro MUI_LANGUAGE "Indonesian"
!insertmacro MUI_LANGUAGE "Mongolian"
!insertmacro MUI_LANGUAGE "Luxembourgish"
!insertmacro MUI_LANGUAGE "Albanian"
!insertmacro MUI_LANGUAGE "Breton"
!insertmacro MUI_LANGUAGE "Belarusian"
!insertmacro MUI_LANGUAGE "Icelandic"
!insertmacro MUI_LANGUAGE "Malay"
!insertmacro MUI_LANGUAGE "Bosnian"
!insertmacro MUI_LANGUAGE "Kurdish"
!insertmacro MUI_LANGUAGE "Irish"
!insertmacro MUI_LANGUAGE "Uzbek"
!insertmacro MUI_LANGUAGE "Galician"
!insertmacro MUI_LANGUAGE "Afrikaans"
>;--------------------------------
;Reserve Files
;If you are using solid compression, files that are required before
;the actual installation should be stored first in the data block,
;
!insertmacro MUI_RESERVEFILE_LANGDLL
>;--------------------------------
;Installer Functions
>Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "Sk643Sk") i .r1 ?e'
Pop $R0
StrCmp $R0 0+3
MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running."
Abort
IfFileExists"$INSTDIR\Uninstall.exe" 0 ContinueInstalling
MessageBox MB_YESNO|MB_ICONQUESTION "It is recommanded that you'll uninstall previously installed versions! Uninstall now?" IDNO ContinueInstalling
WriteRegStr HKCU "Software\SKs\USDownloader" "RestartInstaller" "1"
ExecShell "open" "$INSTDIR\Uninstall.exe"
Abort
ContinueInstalling:
>FunctionEnd
>Function StartReconnector
ExecShell "open" "$INSTDIR\Reconnect (1.0B).exe"
>FunctionEnd
>;--------------------------------
;Installer Sections
Section "USDownloader"
SetOverwrite on
SetOutPath "$INSTDIR"
;ADD YOUR OWN FILES HERE...
IfFileExists "$INSTDIR\USDownloader.ini" 0 +2
MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to save the previous USD settings?" IDYES DontCopy
File "C:\USDBCKUP\Installations\USDownloader_SK\USDownloader.ini"
DontCopy:
File /r "C:\USDBCKUP\Installations\USDownloader_SK\USDownloader\*.*"
;Store installation folder
WriteRegStr HKCU "Software\SKs\USDownloader" "" "$INSTDIR"
;Store installation info for windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SKs USDownloader" "DisplayName" "SK's USDownloader"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SKs USDownloader" "UninstallString" "$INSTDIR\Uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SKs USDownloader" "InstallLocation" "$INSTDIR\"
WriteRegStr HKLM "SoftwareMicrosoftWindowsCurrentVersionUninstallSKs USDownloader" "Publisher" "SK. For The Greater Good!"
WriteRegDWORD HKLM "SoftwareMicrosoftWindowsCurrentVersionUninstallSKs USDownloader" "NoModify " 1
WriteRegDWORD HKLM "SoftwareMicrosoftWindowsCurrentVersionUninstallSKs USDownloader" "NoRepair " 1
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
CreateDirectory "$SMPROGRAMS$STARTMENU_FOLDER"
CreateShortCut "$SMPROGRAMS$STARTMENU_FOLDERUSDownloader.lnk" "$INSTDIRUSDownloader.exe"
CreateShortCut "$SMPROGRAMS$STARTMENU_FOLDERRS_ServerSwitch.lnk" "$INSTDIRRS_ServerSwitch.exe"
CreateShortCut "$SMPROGRAMS$STARTMENU_FOLDERUninstall.lnk" "$INSTDIRUninstall.exe"
CreateDirectory "$SMPROGRAMS$STARTMENU_FOLDERDownload Sites"
CreateShortCut "$SMPROGRAMS$STARTMENU_FOLDERDownload SitesFXP.co.il.lnk" "$INSTDIRDownloadSites!!!FXP.co.il - קהילות מפולחות תוכן.URL"
CreateShortCut "$SMPROGRAMS$STARTMENU_FOLDERDownload SitesPhazeDDL.com.lnk" "$INSTDIRDownloadSites!!!PhazeDDL.com - Full Downloads, Games, Movies & Warez.URL"
CreateShortCut "$SMPROGRAMS$STARTMENU_FOLDERDownload SitesDirectDl.lnk" "$INSTDIRDownloadSites!!!DirectDl.URL"
CreateShortCut "$SMPROGRAMS$STARTMENU_FOLDERDownload SitesDDLSpot.lnk" "$INSTDIRDownloadSites!!!ddlSpot.URL"
CreateShortCut "$SMPROGRAMS$STARTMENU_FOLDERDownload SitesForumW.org.lnk" "$INSTDIRDownloadSites!!!ForumW.org.URL"
CreateShortCut "$SMPROGRAMS$STARTMENU_FOLDERDownload SitesWarezforum.lnk" "$INSTDIRDownloadSites!!!Warezforum - Powered by vBulletin.URL"
!insertmacro MUI_STARTMENU_WRITE_END
;Create uninstaller
WriteUninstaller "$INSTDIRUninstall.exe"
MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to create a desktop shortcut?" IDNO DontCreate
CreateShortCut "$DESKTOPUSDownloader (by SK).lnk" "$INSTDIRUSDownloader.exe" "" "" "" "" "" ""
DontCreate:
SectionEnd
;--------------------------------
;Uninstaller Section
Section "Uninstall"
;ADD YOUR OWN FILES HERE...
MessageBox MB_YESNO|MB_ICONQUESTION "You are about to DELETE the folder: '$INSTDIR', Are You Sure ?!" IDNO ABORTOP
Delete "$INSTDIRUninstall.exe"
Delete "$DESKTOPUSDownloader (by SK).lnk"
IfFileExists "$INSTDIRUSDownloader.ini" 0 +4
MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to save the previous USD settings?" IDNO DontSave
StrCpy $SAVEDFILE 1
CopyFiles /SILENT /FILESONLY "$INSTDIRUSDownloader.ini" "$TEMPUSDownloader.ini" 10
IfFileExists "$INSTDIRUSDownloader.lst" 0 +2
CopyFiles /SILENT /FILESONLY "$INSTDIRUSDownloader.lst" "$TEMPUSDownloader.lst" 10
IfFileExists "$INSTDIRDecryptionCheck.ini" 0 +2
CopyFiles /SILENT /FILESONLY "$INSTDIRDecryptionCheck.ini" "$TEMPDecryptionCheck.ini" 10
IfFileExists "$INSTDIRReconnect.ini" 0 +2
CopyFiles /SILENT /FILESONLY "$INSTDIRReconnect.ini" "$TEMPReconnect.ini" 10
Goto ContinueOperation
DontSave:
StrCpy $SAVEDFILE 0
ContinueOperation:
RMDir /r "$INSTDIR"
!insertmacro MUI_STARTMENU_GETFOLDER Application "$MUI_TEMP"
Delete "$SMPROGRAMS$MUI_TEMPUninstall.lnk"
RMDir /r "$SMPROGRAMS$MUI_TEMP"
;Delete empty start menu parent diretories
StrCpy $MUI_TEMP "$SMPROGRAMS$MUI_TEMP"
startMenuDeleteLoop:
ClearErrors
RMDir /r "$MUI_TEMP"
GetFullPathName "$MUI_TEMP" "$MUI_TEMP.."
IfErrors startMenuDeleteLoopDone
StrCmp "$MUI_TEMP" "$SMPROGRAMS" startMenuDeleteLoopDone startMenuDeleteLoop
startMenuDeleteLoopDone:
${If} $SAVEDFILE = 1
CreateDirectory "$INSTDIR"
CopyFiles /SILENT /FILESONLY "$TEMPUSDownloader.ini" "$INSTDIRUSDownloader.ini" 10
Delete "$TEMPUSDownloader.ini"
IfFileExists "$TEMPUSDownloader.lst" 0 +3
CopyFiles /SILENT /FILESONLY "$TEMPUSDownloader.lst" "$INSTDIRUSDownloader.lst" 10
Delete "$TEMPUSDownloader.lst"
IfFileExists "$TEMPDecryptionCheck.ini" 0 +3
CopyFiles /SILENT /FILESONLY "$TEMPDecryptionCheck.ini" "$INSTDIRDecryptionCheck.ini" 10
Delete "$TEMPDecryptionCheck.ini"
IfFileExists "$TEMPReconnect.ini" 0 +3
CopyFiles /SILENT /FILESONLY "$TEMPReconnect.ini" "$INSTDIRReconnect.ini" 10
Delete "$TEMPReconnect.ini"
${EndIf}
ABORTOP:
ReadRegStr $RestartInstaller HKCU "SoftwareSKsUSDownloader" "RestartInstaller"
${If} $RestartInstaller = "1"
ExecShell "open" "$EXEPATH$EXEFILE"
${EndIf}
DeleteRegKey /ifempty HKCU "SoftwareSKsUSDownloader"
DeleteRegKey /ifempty HKCU "SoftwareSKsUSDownloader"
SectionEnd
>