Archive: Problem with NSIS Code


Problem with NSIS Code
Hey I will make a Function which Copy one File from an folder in an other..

but the user must chose which file he would.

I've write this Code.. but it doesn't work.

What is wrong?

;Configuration
;--------------------------------

; Compressor
SetCompressor zlib

;Don't Display CRC
CRCCheck off

; Define your settigs
!define APPNAME "C-S 1.6 Erweiterungssystem"
!define APPNAMEANDVERSION "C-S 1.6 Erweiterungssystem"
!define MUI_TEXT_WELCOME_INFO_TITLE "Willkommen beim $(^NameDA)"
!define MUI_TEXT_WELCOME_INFO_TEXT "$(^NameDA) wird Sie durch die Installation begleiten.\r\n\r\nEs wird empfohlen, vor der Installation alle anderen Programme zu schließen, damit bei der Installation keine Probleme auftreten.\r\n\r\n$_CLICK"
!define MUI_TEXT_FINISH_INFO_TITLE "$(^NameDA) wird abgeschlossen"
!define MUI_TEXT_FINISH_INFO_TEXT "$(^NameDA) hat die ausgewählten Komponenten erfolgreich installiert.\r\n\r\nWICHTIG: Die Textdatei, die sich nach dem klick auf Fertigstellen öffnet unbedingt lesen!"

; Main Install settings
Name "${APPNAMEANDVERSION}"
InstallDir "Install-Ordner von C-S 1.6"
DirText "Bitte wählen Sie das Verzeichnis von Counter-Strike 1.6 aus indem Sie auf Durchsuchen... klicken (sobald Counter-Strike 1.6 in dem angegebenem Pfad erkannt ist können sie fortfahren):"
InstallDirRegKey HKLM "Software\${APPNAME}" ""
OutFile "Setup.exe"

; ReserveFiles
ReserveFile "connection.ico"

; Variables
Var HWND

; Settings
ShowInstDetails nevershow
ShowUninstDetails hide

!include "MUI.nsh"
!include "Sections.nsh"
!include "LogicLib.nsh"
!include "WinMessages.nsh"

!define MUI_ABORTWARNING

!define MUI_COMPONENTSPAGE_SMALLDESC

; Pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_COMPONENTS
Page custom InformationsPage
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
Page custom NetsettingsPage PageLeaveNetsettings
!define MUI_FINISHPAGE_NOAUTOCLOSE
!insertmacro MUI_PAGE_FINISH

;--------------------------------
; Languages
!insertmacro MUI_LANGUAGE "German"
;--------------------------------

;--------------------------------
; Installer Sections

; Set Section Files and Shortcuts

Section "Config, Netsettings..." Section1

; Set Section properties
SetOverwrite on

;Details
SetDetailsPrint textonly
DetailPrint "Installiere Config, Netsettings..."
SetDetailsPrint listonly

;Netsettings
SetOutPath "$INSTDIR\Infos\Netsettings\"
File "Erweiterungen\CONFIG & MEHR\Infos\Netsettings\Info.txt"
SetOutPath "$INSTDIR\Infos\Netsettings\56K Modem"
File "Erweiterungen\CONFIG & MEHR\Infos\Netsettings\56K_Modem\netsettings.cfg"
SetOutPath "$INSTDIR\Infos\Netsettings\A-DSL"
File "Erweiterungen\CONFIG & MEHR\Infos\Netsettings\A-DSL\netsettings.cfg"
SetOutPath "$INSTDIR\Infos\Netsettings\Cable"
File "Erweiterungen\CONFIG & MEHR\Infos\Netsettings\Cable\netsettings.cfg"
SetOutPath "$INSTDIR\Infos\Netsettings\D-ISDN"
File "Erweiterungen\CONFIG & MEHR\Infos\Netsettings\D-ISDN\netsettings.cfg"
SetOutPath "$INSTDIR\Infos\Netsettings\DSL mit FP"
File "Erweiterungen\CONFIG & MEHR\Infos\Netsettings\DSL_mit_FP\netsettings.cfg"
SetOutPath "$INSTDIR\Infos\Netsettings\ISDN"
File "Erweiterungen\CONFIG & MEHR\Infos\Netsettings\ISDN\netsettings.cfg"
SetOutPath "$INSTDIR\Infos\Netsettings\LAN"
File "Erweiterungen\CONFIG & MEHR\Infos\Netsettings\LAN\netsettings.cfg"
SetOutPath "$INSTDIR\Infos\Netsettings\Q-DSL"
File "Erweiterungen\CONFIG & MEHR\Infos\Netsettings\Q-DSL\netsettings.cfg"
SetOutPath "$INSTDIR\Infos\Netsettings\S-DSL"
File "Erweiterungen\CONFIG & MEHR\Infos\Netsettings\S-DSL\netsettings.cfg"

Call CopyNetsettings
;Netsettings End
SectionEnd

Section -FinishSection

; Details
SetDetailsPrint none

WriteRegStr HKLM "Software\${APPNAME}" "" "$INSTDIR"

; Details
SetDetailsPrint textonly
DetailPrint "...Fertig"
SetDetailsPrint listonly

SectionEnd

; Modern install component descriptions
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${Section1} "Verbesserte Config, Netsettings"
!insertmacro MUI_FUNCTION_DESCRIPTION_END

; Funtions

Function .onInit

!insertmacro MUI_INSTALLOPTIONS_EXTRACT "connection.ico"

WriteINIStr $PLUGINSDIR\netsettings.ini "Field 2" "Text" $PLUGINSDIR\connection.ico

FunctionEnd

; Netsettings Page
Function NetsettingsPage
!insertmacro SectionFlagIsSet ${Section1} ${SF_SELECTED} ShowPage SkipPage
ShowPage:

GetDlgItem $R0 $HWNDPARENT 2
EnableWindow $R0 0|1 # 0=hide, 1=show
GetDlgItem $R0 $HWNDPARENT 3
ShowWindow $R0 ${SW_HIDE}
!insertmacro MUI_HEADER_TEXT "Konfiguration des Erweiterungs System" "Wählen Sie, mit welcher Verbindung sie spielen."
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "netsettings.ini"

SkipPage:

FunctionEnd

; Copy Files
!macro COPY_FILES SOURCE
CopyFiles /silent "$INSTDIR\Infos\Netsettings\${SOURCE}\netsettings.cfg" "$INSTDIR\cstrike\"
goto done
!macroend

; Copy Netsettings
Function CopyNetsettings

Push $R0
ReadINIStr $R0 "$PLUGINSDIR\netsettings.ini" "Field 1" "State"

StrCmp $R0 "LAN" 0 notLAN
!insertmacro COPY_FILES LAN
notLAN:

StrCmp $R0 "56K Modem" 0 not56K_Modem
!insertmacro COPY_FILES 56K_Modem
not56K_Modem:

StrCmp $R0 "ISDN" 0 notISDN
!insertmacro COPY_FILES ISDN
notISDN:

StrCmp $R0 "D-ISDN" 0 notD-ISDN
!insertmacro COPY_FILES D-ISDN
notD-ISDN:

StrCmp $R0 "S-DSL" 0 notS-DSL
!insertmacro COPY_FILES S-DSL
notS-DSL:

StrCmp $R0 "A-DSL" 0 notA-DSL
!insertmacro COPY_FILES A-DSL
notA-DSL:

StrCmp $R0 "Cable" 0 notCable
!insertmacro COPY_FILES Cable
notCable:

StrCmp $R0 "Q-DSL" 0 notQ-DSL
!insertmacro COPY_FILES Q-DSL
notQ-DSL:

StrCmp $R0 "DSL mit FP" 0 done
!insertmacro COPY_FILES DSL_mit_FP
done:

Pop $R0
FunctionEnd

BrandingText "Counter-Strike 1.6 Erweiterungssystem"


Here is the the Complete Folder with all files.

Please help me
THANKS

Hey i've here a new file because in the old was something wrong.

Please help me

Why doesn't works my copy file function?

Sorry that my english isn't very good.

Here is it:


Pretty sure you need to put the file name on the destination path as well:

CopyFiles /silent "$INSTDIR\Infos\Netsettings\${SOURCE}\netsettings.cfg" "$INSTDIR\cstrike\netsettings.cfg"

-Stu


Hy thanks for your answer I've change it now. But it doesn't work.

Could you say me why?

Thank you.


You have a mistake in your script.

You call the function CopyNetSettings within the section, but this code is executed before the user choses the connection type.

Move the call out of the section as stated below:

Function .OnGUIEnd
Call CopyNetsettings
FunctionEnd

This way the section is executed, than the InstallOptions Page is shown, and last but not least your copy function is finally called.