!define VERSION "1.0.0.1"
!define VER_DATE "(v27.5)"
;--------------------------------
;Include Modern UI
!include "MUI.nsh"
!include "Sections.nsh"
!include "LogicLib.nsh"
!include "Memento.nsh"
!include "WordFunc.nsh"

;--------------------------------
;Configuration
OutFile "SK's USDownloader ${VER_DATE}.exe"

InstType "Full"
InstType "Lite"
InstType "SK's Tools"

;Style
!insertmacro VersionCompare
!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 HKLM "Software\SKs\USDownloader" ""

RequestExecutionLevel admin

;--------------------------------
;Definitions:
  !define SHCNE_ASSOCCHANGED 0x8000000
  !define SHCNF_IDLIST 0
;--------------------------------
;Configuration

;Name and file
  Name "USDownloader"
  Caption "SK's USDownloader ${VER_DATE}"

;Memento Settings
  !define MEMENTO_REGISTRY_ROOT HKLM
  !define MEMENTO_REGISTRY_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\SKs USDownloader"

;Interface Settings
  !define MUI_ABORTWARNING

  !define MUI_HEADERIMAGE
  !define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\orange-nsis.bmp" ; optional

  !define MUI_COMPONENTSPAGE_SMALLDESC

;--------------------------------
;Pages

  !insertmacro MUI_PAGE_LICENSE "C:\USDBCKUP\Installations\License.txt"
  !ifdef VERSION
  Page custom PageReinstall PageLeaveReinstall
  !endif
  !insertmacro MUI_PAGE_COMPONENTS
  !insertmacro MUI_PAGE_DIRECTORY
  
  !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
  
;--------------------------------
;Variables
  Var SAVEDFILE
;--------------------------------
;Language Selection Dialog Settings

  ;Remember the installer language
  !define MUI_LANGDLL_REGISTRY_ROOT "HKLM" 
  !define MUI_LANGDLL_REGISTRY_KEY "Software\SKs\USDownloader" 
  !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
  
;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"
;--------------------------------
  VIProductVersion "1.0.0.1"
  VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "SK's USDownloader ${VER_DATE}"
  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 ${VER_DATE}"
  VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "1.0.0.1"
;--------------------------------
;Reserve Files
  
  ;If you are using solid compression, files that are required before
  ;the actual installation should be stored first in the data block,
  ;because this will make your installer start faster.
  ReserveFile "SK's USDownloader.ini"
  !insertmacro MUI_RESERVEFILE_LANGDLL
  !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
;--------------------------------
;Installer Sections
SetOverwrite on
SectionGroup /e "USDownloader" SecUSDGroup
${MementoSection} "USDownloader (required)" SecUSD

  SetDetailsPrint textonly
  DetailPrint "Installing USDownloader | 'Dimoniusis' Latest version..."
  SetDetailsPrint listonly
  
  SectionIn 1 2 RO
  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\USD\*.*"
${MementoSectionEnd}

${MementoSection} "USDownloader's plugins" SecPlugins
  SetDetailsPrint textonly
  DetailPrint "Installing USDownloader | USDownloader's plugins..."
  SetDetailsPrint listonly

  SectionIn 1 2
  
  SetOutPath "$INSTDIR\Plugins"
  File /r "C:\USDBCKUP\Installations\USDownloader_SK\USDownloader\Plugins\*.*"
${MementoSectionEnd}

${MementoSection} "Start Menu and Desktop Shortcut" SecStartMenu
  SetDetailsPrint textonly
  DetailPrint "Installing USDownloader | Start Menu and Desktop Shortcut..."
  SetDetailsPrint listonly

  SectionIn 1 2
  
  SetOutPath "$INSTDIR"
    ;make Start-Menu programs dir!
  	CreateDirectory "$SMPROGRAMS\SK's USDownloder"
	CreateShortCut "$SMPROGRAMS\SK's USDownloder\USDownloader.lnk" "$INSTDIR\USDownloader.exe"
	CreateShortCut "$SMPROGRAMS\SK's USDownloder\RS_ServerSwitch.lnk" "$INSTDIR\RS_ServerSwitch.exe"
	CreateShortCut "$SMPROGRAMS\SK's USDownloder\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
	CreateDirectory "$SMPROGRAMS\SK's USDownloder\Download Sites"
	CreateShortCut "$SMPROGRAMS\SK's USDownloder\Download Sites\FXP.co.il.lnk" "$INSTDIR\DownloadSites!!!\FXP.co.il - קהילות מפולחות תוכן.URL"
	CreateShortCut "$SMPROGRAMS\SK's USDownloder\Download Sites\PhazeDDL.com.lnk" "$INSTDIR\DownloadSites!!!\PhazeDDL.com - Full Downloads, Games, Movies & Warez.URL"
	CreateShortCut "$SMPROGRAMS\SK's USDownloder\Download Sites\DirectDl.lnk" "$INSTDIR\DownloadSites!!!\DirectDl.URL"
	CreateShortCut "$SMPROGRAMS\SK's USDownloder\Download Sites\DDLSpot.lnk" "$INSTDIR\DownloadSites!!!\ddlSpot.URL"
	CreateShortCut "$SMPROGRAMS\SK's USDownloder\Download Sites\ForumW.org.lnk" "$INSTDIR\DownloadSites!!!\ForumW.org.URL"
	CreateShortCut "$SMPROGRAMS\SK's USDownloder\Download Sites\Warezforum.lnk" "$INSTDIR\DownloadSites!!!\Warezforum - Powered by vBulletin.URL"
  ;make shortcut
  MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to create a desktop shortcut?" IDNO DontCreate
  CreateShortCut "$DESKTOP\USDownloader (by SK).lnk" "$INSTDIR\USDownloader.exe"
  DontCreate:
${MementoSectionEnd}
SectionGroupEnd

;============================================================================

SectionGroup /e "SK's USDownloder Tools" SecSKsGroup
${MementoSection} "DecryptionCheck" SecDC
  SetDetailsPrint textonly
  DetailPrint "Installing SK's USDownloder Tools | DecryptionCheck..."
  SetDetailsPrint listonly

  SectionIn 1 3
  
  SetOutPath "$INSTDIR"
  File /r "C:\USDBCKUP\Installations\USDownloader_SK\USDownloader\DecryptionCheck\*.*"
${MementoSectionEnd}

${MementoSection} "ServerSwitch" SecSS
  SetDetailsPrint textonly
  DetailPrint "Installing SK's USDownloder Tools | ServerSwitch..."
  SetDetailsPrint listonly

  SectionIn 1 3
  
  SetOutPath "$INSTDIR"
  File /r "C:\USDBCKUP\Installations\USDownloader_SK\USDownloader\ServerSwitch\*.*"
${MementoSectionEnd}

${MementoSection} "Auto'Reconnect" SecR
  SetDetailsPrint textonly
  DetailPrint "Installing SK's USDownloder Tools | Auto'Reconnect..."
  SetDetailsPrint listonly

  SectionIn 1 3
  
  SetOutPath "$INSTDIR"
  File /r "C:\USDBCKUP\Installations\USDownloader_SK\USDownloader\Reconnect\*.*"
${MementoSectionEnd}

${MementoSection} "Spam & Macro Bot" SecSNM
  SetDetailsPrint textonly
  DetailPrint "Installing SK's USDownloder Tools | Spam & Macro Bot..."
  SetDetailsPrint listonly

  SectionIn 1 3
  
  SetOutPath "$INSTDIR"
  File /r "C:\USDBCKUP\Installations\USDownloader_SK\USDownloader\SpamBot\*.*"
${MementoSectionEnd}

${MementoSection} "Download sites directory" SecDDL
  SetDetailsPrint textonly
  DetailPrint "Installing SK's USDownloder Tools | Download sites directory..."
  SetDetailsPrint listonly

  SectionIn 1 3
  
  SetOutPath "$INSTDIR\DownloadSites!"
  File /r "C:\USDBCKUP\Installations\USDownloader_SK\USDownloader\DownloadSites\*.*"
${MementoSectionEnd}
${MementoSectionDone}
SectionGroupEnd

Section -post
  ;Store installation folder
  WriteRegStr HKLM "Software\SKs\USDownloader" "" "$INSTDIR"
  ;Store installation version
  WriteRegStr HKLM "Software\SKs\USDownloader" "Version" "${VERSION}"
  ;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 "Software\Microsoft\Windows\CurrentVersion\Uninstall\SKs USDownloader" "Publisher" "SK. For The Greater Good!"
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SKs USDownloader" "NoModify " 1
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SKs USDownloader" "NoRepair " 1
	
  ;make uninstaller
  WriteUninstaller "$INSTDIR\Uninstall.exe"
  ${MementoSectionSave}

  SetDetailsPrint both
SectionEnd
;--------------------------------
;Descriptions

!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  !insertmacro MUI_DESCRIPTION_TEXT ${SecUSDGroup} "'Dimoniusis' Latest USDownloader version as is."
  !insertmacro MUI_DESCRIPTION_TEXT ${SecUSD} "USDownloader '.exe' file and the language package alone."
  !insertmacro MUI_DESCRIPTION_TEXT ${SecPlugins} "USDownloader plugins package."
  !insertmacro MUI_DESCRIPTION_TEXT ${SecStartMenu} "Start Menu and Desktop Shortcut! "
  !insertmacro MUI_DESCRIPTION_TEXT ${SecSKsGroup} "All you can possibly need in order to fully automate the download process of USDownloader!"
  !insertmacro MUI_DESCRIPTION_TEXT ${SecDC} "Decrypts RapidShare's password pictures using FineReader 8\nChecks & Downloads SK's latest updates!"
  !insertmacro MUI_DESCRIPTION_TEXT ${SecSS} "Allows the users to switch the preffered 'RapidShare' server"
  !insertmacro MUI_DESCRIPTION_TEXT ${SecR} "Preforms automatic internet re'connection putting a sharp emphasis on IP renewal!"
  !insertmacro MUI_DESCRIPTION_TEXT ${SecSNM} "Allows users to generate a macro that automates routers reconnections."
  !insertmacro MUI_DESCRIPTION_TEXT ${SecDDL} "A list of SK's most favorite direct downloads supplying sites!"
!insertmacro MUI_FUNCTION_DESCRIPTION_END
;--------------------------------
;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

!ifdef VERSION
  !insertmacro MUI_INSTALLOPTIONS_EXTRACT "SK's USDownloader.ini"
!endif

${MementoSectionRestore}

FunctionEnd

!ifdef VERSION
Function PageReinstall

  ReadRegStr $R0 HKLM "Software\SKs\USDownloader" ""
  ReadRegStr $3 HKLM "Software\SKs\USDownloader" "Version"
  StrCmp $R0 "" 0 +2
    Abort

  ${VersionCompare} ${3} ${VERSION} $4
  IntCmp ${4} 1 older_version  new_version same_version

  new_version:

   !insertmacro MUI_INSTALLOPTIONS_WRITE "SK's USDownloader.ini" "Field 1" "Text" "An older version of SK's USDownloader is installed on your system. It's recommended that you uninstall the current version before installing. Select the operation you want to perform and click Next to continue."
   !insertmacro MUI_INSTALLOPTIONS_WRITE "SK's USDownloader.ini" "Field 2" "Text" "Uninstall before installing"
   !insertmacro MUI_INSTALLOPTIONS_WRITE "SK's USDownloader.ini" "Field 3" "Text" "Do not uninstall"
   !insertmacro MUI_HEADER_TEXT "Already Installed" "Choose how you want to install SK's USDownloader."
   StrCpy $R0 "1"
   Goto reinst_start

  older_version:

   !insertmacro MUI_INSTALLOPTIONS_WRITE "SK's USDownloader.ini" "Field 1" "Text" "A newer version of SK's USDownloader is already installed! It is not recommended that you install an older version. If you really want to install this older version, it's better to uninstall the current version first. Select the operation you want to perform and click Next to continue."
   !insertmacro MUI_INSTALLOPTIONS_WRITE "SK's USDownloader.ini" "Field 2" "Text" "Uninstall before installing"
   !insertmacro MUI_INSTALLOPTIONS_WRITE "SK's USDownloader.ini" "Field 3" "Text" "Do not uninstall"
   !insertmacro MUI_HEADER_TEXT "Already Installed" "Choose how you want to install SK's USDownloader."
   StrCpy $R0 "1"
   Goto reinst_start

  same_version:

   !insertmacro MUI_INSTALLOPTIONS_WRITE "SK's USDownloader.ini" "Field 1" "Text" "SK's USDownloader ${VER_DATE} is already installed. Select the operation you want to perform and click Next to continue."
   !insertmacro MUI_INSTALLOPTIONS_WRITE "SK's USDownloader.ini" "Field 2" "Text" "Add/Reinstall components"
   !insertmacro MUI_INSTALLOPTIONS_WRITE "SK's USDownloader.ini" "Field 3" "Text" "Uninstall SK's USDownloader"
   !insertmacro MUI_HEADER_TEXT "Already Installed" "Choose the maintenance option to perform."
   StrCpy $R0 "2"

  reinst_start:

  !insertmacro MUI_INSTALLOPTIONS_DISPLAY "SK's USDownloader.ini"

FunctionEnd

Function PageLeaveReinstall

  !insertmacro MUI_INSTALLOPTIONS_READ $R1 "SK's USDownloader.ini" "Field 2" "State"

  StrCmp $R0 "1" 0 +2
    StrCmp $R1 "1" reinst_uninstall reinst_done

  StrCmp $R0 "2" 0 +3
    StrCmp $R1 "1" reinst_done reinst_uninstall

  reinst_uninstall:
  ReadRegStr $R1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SKs USDownloader" "UninstallString"

  ;Run uninstaller
  HideWindow

    ClearErrors
    ExecWait '$R1 _?=$INSTDIR'

    IfErrors no_remove_uninstaller
    IfFileExists "$INSTDIR\USDownloader.exe" no_remove_uninstaller

      Delete $R1
      RMDir $INSTDIR

    no_remove_uninstaller:

  StrCmp $R0 "2" 0 +2
    Quit

  BringToFront

  reinst_done:

FunctionEnd

!endif

Function StartReconnector
ExecShell "open" "$INSTDIR\Reconnect (1.0B).exe"
FunctionEnd

;--------------------------------
;Uninstaller Section

Section "Uninstall"

  ;ADD YOUR OWN FILES HERE...
  
  SetDetailsPrint textonly
  DetailPrint "Uninstalling SK's USDownloader..."
  SetDetailsPrint listonly
  
  StrCmp $INSTDIR "" 0 +3
  MessageBox MB_OK|MB_ICONSTOP "Install path missing!"
  Abort
  
  IfFileExists "$INSTDIR\USDownloader.exe" already_installed
    MessageBox MB_YESNO "It does not appear that SK's USDownloader is installed in the directory '$INSTDIR'.$\r$\nContinue anyway (not recommended)?" IDYES already_installed
    Abort "Uninstall aborted by user"
  already_installed:
  ;;;;
  
  MessageBox MB_YESNO|MB_ICONQUESTION "You are about to DELETE the folder: '$INSTDIR', Are You Sure ?!" IDNO ABORTOP
  
  IfFileExists "$INSTDIR\USDownloader.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 "$INSTDIR\USDownloader.ini" "$TEMP\USDownloader.ini" 10
  IfFileExists "$INSTDIR\USDownloader.lst" 0 +2
  CopyFiles /SILENT /FILESONLY "$INSTDIR\USDownloader.lst" "$TEMP\USDownloader.lst" 10
  IfFileExists "$INSTDIR\DecryptionCheck.ini" 0 +2
  CopyFiles /SILENT /FILESONLY "$INSTDIR\DecryptionCheck.ini" "$TEMP\DecryptionCheck.ini" 10
  IfFileExists "$INSTDIR\Reconnect.ini" 0 +2
  CopyFiles /SILENT /FILESONLY "$INSTDIR\Reconnect.ini" "$TEMP\Reconnect.ini" 10
  Goto ContinueOperation
  DontSave:
  StrCpy $SAVEDFILE 0
  ContinueOperation:
  
  SetDetailsPrint textonly
  DetailPrint "Deleting Registry Keys..."
  SetDetailsPrint listonly
  
  DeleteRegKey /ifempty HKLM "Software\SKs\USDownloader"
  DeleteRegKey /ifempty HKLM "Software\SK"
  DeleteRegKey /ifempty HKLM "Software\SK's\USDownloader"
  DeleteRegKey /ifempty HKLM "Software\SK's"
  
  SetDetailsPrint textonly
  DetailPrint "Deleting Files..."
  SetDetailsPrint listonly
  
  Delete "$INSTDIR\Uninstall.exe"
  Delete "$DESKTOP\USDownloader (by SK).lnk"
  RMDir /r "$SMPROGRAMS\SK's USDownloder"
  RMDir /r "$INSTDIR\Plugins"
  RMDir /r "$INSTDIR\Langs"
  RMDir /r "$INSTDIR\BckUp"
  RMDir /r "$INSTDIR\DownloadSites!"
  RMDir /r "$INSTDIR\Icons"
  RMDir /r "$INSTDIR\WrongCaptch"
  RMDir /r "$INSTDIR\BMP_RS"
  FindFirst $0 $1 "$INSTDIR\*.*"
	loop:
  StrCmp $1 "" done
  Delete "$INSTDIR\$1"
  FindNext $0 $1
  Goto loop
  done:
  
  RMDir "$INSTDIR"

  
  ${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}
  ABORTOP:
  	SetDetailsPrint both
	
SectionEnd