Archive: Including Files HELP!!


Including Files HELP!!
OK, I am using the windows version and i need to include about 7 exe files, and i know that it will be a long download from my website but it is needed. I had the idea of the installer creating a folder in the Program Files (the users will only be using XP) and it would place these 7 exe files in there (It wouldnt matter what the user selected that they wantred to download the all would still be placed in there). Then the script would execute them from that directory depending on if they wanted to use those files.

Then at the end of the Installer (before the finish page) it would delete these setup files.

Is any of this even possible? I know the exec command but it isnt including the files for some reason.

Any help would be appreciated. Thanks in advance

Skeezmo


To extract files, use the File command. See Examples\example1.nsi for the simplest example.


Thank you for your reply kichik. And then what exactly would i do about the removing the files and directory when the installer is done. I am very sorry, I am sort of a newbie at this.


Something like this, perhaps.

Section
SetOutPath "$INSTDIR"
File "MyApp.exe"
ExecWait '"$INSTDIR\MyApp.exe"'
Delete "$INSTDIR\MyApp.exe"
RMDir "$INSTDIR"
SectionEnd
You'll need to use ExecWait otherwise Delete and RMDir won't work unless you specify /REBOOTOK.

RMDir "$INSTDIR" on its own will not work unless $INSTDIR is completely empty.
Use RMDir /r "$INSTDIR" (recursive delete).

-Stu


But what if $INSTDIR happens to be a directory that already exists and contains additional files, such as "C:\Windows"? Wouldn't it be wiser not to use RMDir /r to avoid deleting something you didn't intend to? In my example, RMDir fails gracefully if the directory turns out not to be empty.


so what one should i use. And stu where would i put that command?


See scrose's code.

-Stu


It works very well so far, but one problem. It wont let me not install something in the first place. It doesnt pay any attention to what the user selected. IT installs it all.

Here is my .nsi file. I dont know if it will actually help, but ya.

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

OutFile ..\silverfox.exe
SetCompressor lzma

InstallDir $PROGRAMFILES\SFR

;--------------------------------
;Header Files

!include "MUI.nsh"
!include "Sections.nsh"


;--------------------------------
;Definitions

!define SHCNE_ASSOCCHANGED 0x8000000
!define SHCNF_IDLIST 0

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

;Names
Name "Silverfox Radio DJ Install"
Caption "Broadcasting Tools Setup"
Icon "..\Contrib\Graphics\Icons\stock_revert.ico"
BGGradient 99ffcc 9999ff 000000
;Interface Settings
!define MUI_ABORTWARNING

!define MUI_HEADERIMAGE
!define MUI_WELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\orange.bmp"

!define MUI_COMPONENTSPAGE_SMALLDESC

;Pages
!define MUI_WELCOMEPAGE_TITLE "Welcome to the Silverfox Broadcasting Tools Center"
!define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation \
of the programs needed in order to DJ with Silverfox Radio. SAM2 Broadcaster \
(Streaming Audio Manager Version 2) is a required download, we do nto permit any \
other broadcasting software. You will also have the options of installing instant \
messaging programs, an FTP Program (for playlist and request files), and also a \
new SFR Beta Program TeamSpeak(tm)\r\n\r\(SFR is in no way affiliated with Spacial \
Audio or Tesm Speak)\r\n\r\n$_CLICK"

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "..\license.txt"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES

!define MUI_FINISHPAGE_LINK "Visit the Silverfox DJ Section on the Web. You \
will need to register with Skeezmo before you will be able to log in."
!define MUI_FINISHPAGE_LINK_LOCATION "http://silverfoxradio.com/restricted/"

!define MUI_FINISHPAGE_NOREBOOTSUPPORT

!insertmacro MUI_PAGE_FINISH

;--------------------------------
;Languages

!insertmacro MUI_LANGUAGE "English"

;--------------------------------

;Installer Sections
Section "SAM2 Broadcaster" SecSAM
SectionIn RO
SetOutPath "$INSTDIR"
File "..\Examples\license.txt"
File "..\Examples\SAMInstall.exe"
ExecWait '"$INSTDIR\SAMInstall.exe"'
SetDetailsPrint textonly
DetailPrint "Installing Streaming Audio Manager 2..."
SetDetailsPrint listonly
Delete "$INSTDIR\SAMInstall.exe"
SectionEnd
Section "SFR Help Files" SecHelp
SectionIn RO
SetOutPath "C:\Silverfox Radio\Help"
File "..\Examples\help.zip"
ExecWait '"$INSTDIR\help.zip"'
SetDetailsPrint textonly
DetailPrint "Installing Silverfox Help Files..."
SetDetailsPrint listonly
SectionEnd
SubSection Instant Messengers
Section "Yahoo Instant Messenger" SecYIM
SetOutPath "$INSTDIR"
File "..\Examples\YIMInstall.exe"
ExecWait '"$INSTDIR\YIMInstall.exe"'
SetDetailsPrint textonly
DetailPrint "Installing Yahoo Instant Messenger..."
SetDetailsPrint listonly
Delete "$INSTDIR\YIMInstall.exe"
SectionEnd

Section "AOL Instant Messenger" SecAIM
SetOutPath "$INSTDIR"
File "..\Examples\AIMInstall.exe"
ExecWait '"$INSTDIR\AIMInstall.exe"'
SetDetailsPrint textonly
DetailPrint "Installing AOL Instant Messenger..."
SetDetailsPrint listonly
Delete "$INSTDIR\AIMInstall.exe"
SectionEnd

Section "Windows Instant Messenger" SecWind
SetOutPath "$INSTDIR"
File "..\Examples\WINDInstall.exe"
ExecWait '"$INSTDIR\WINDInstall.exe"'
SetDetailsPrint textonly
DetailPrint "Installing Windows Instant Messenger..."
SetDetailsPrint listonly
Delete "$INSTDIR\WINDInstall.exe"
SectionEnd

Section "ICQ Instant Messenger" SecICQ
SetOutPath "$INSTDIR"
File "..\Examples\ICQInstall.exe"
ExecWait '"$INSTDIR\ICQInstall.exe"'
SetDetailsPrint textonly
DetailPrint "Installing ICQ Instant Messenger..."
SetDetailsPrint listonly
Delete "$INSTDIR\ICQInstall.exe"
SectionEnd
SubSectionEnd
Section "Ares Lite Edition" g1o1
SetOutPath "$INSTDIR"
File "..\Examples\ARESInstall.exe"
ExecWait '"$INSTDIR\ARESInstall.exe"'
SetDetailsPrint textonly
DetailPrint "Installing Ares Lite Edition..."
SetDetailsPrint listonly
Delete "$INSTDIR\ARESInstall.exe"
SectionEnd
Section "Ares Lite Edition" g1o2
SetOutPath "$INSTDIR"
File "..\Examples\ARESFInstall.exe"
ExecWait '"$INSTDIR\ARESFInstall.exe"'
SetDetailsPrint textonly
DetailPrint "Installing Ares Full Edition..."
SetDetailsPrint listonly
Delete "$INSTDIR\ARESFInstall.exe"
SectionEnd
Function .onInit
StrCpy $1 ${g1o1}
FunctionEnd
Function .onSelChange
!insertmacro StartRadioButtons $1
!insertmacro RadioButton ${g1o1}
!insertmacro RadioButton ${g1o2}
!insertmacro EndRadioButtons
FunctionEnd
Section "Wise FTP" SecFTP
SetOutPath "$INSTDIR"
File "..\Examples\WISEInstall.exe"
ExecWait '"$INSTDIR\WISEInstall.exe"'
SetDetailsPrint textonly
DetailPrint "Installing Wise FTP..."
SetDetailsPrint listonly
Delete "$INSTDIR\WISEInstall.exe"
SectionEnd

;--------------------------------
;Descriptions

!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SecSAM} \
"Streaming Audio Manager 2{v2.83} -- Required Download"
!insertmacro MUI_DESCRIPTION_TEXT ${SecYIM} \
"Yahoo Instant Messenger Only Install if not already"
!insertmacro MUI_DESCRIPTION_TEXT ${SecAIM} \
"AOL Instant Messenger{V5.9.3690} Only Install if not already"
!insertmacro MUI_DESCRIPTION_TEXT ${SecWind} \
"Windows Messenger{v6.2} Only Install if not already"
!insertmacro MUI_DESCRIPTION_TEXT ${SecICQ} \
"ICQ Instant Messenger{v4} Only Install if not already"
!insertmacro MUI_DESCRIPTION_TEXT ${SecFTP} \
"Wise FTP {v3.0.0.7} Provided by 1and1.com -- No need to \
install if you already have an FTP of your choice"
!insertmacro MUI_DESCRIPTION_TEXT ${SecHelp} \
"Installs Help Information for Silverfox Radio DJs -- Required Download"
!insertmacro MUI_DESCRIPTION_TEXT ${SecAres} \
"Ares Editions P2P software"
!insertmacro MUI_FUNCTION_DESCRIPTION_END

;--------------------------------
;Installer Functions

!macro secSelected SEC
SectionGetFlags ${SEC} $R7
IntOp $R7 $R7 & ${SF_SELECTED}
IntCmp $R7 ${SF_SELECTED} 0 +2 +2
IntOp $R0 $R0 + 1
!macroend


Thanks in advance.

Skeezmo

I tested your script and found it worked okay. I was able to perform a custom install without a problem. Have I correctly understood your question?

A couple suggestions regarding your script.

1) For your second "Ares Lite Edition" section, you should use the /o parameter to have it initially unselected, as I think is your intent with the RadioButton macro.

Section /o "Ares Lite Edition" g1o2
2) You probably should place each group of SetDetailsPrint and DetailPrint commands before each ExecWait, otherwise your message will not be displayed until each installation has completed. For example:
Section "SAM2 Broadcaster" SecSAM
SectionIn RO
SetDetailsPrint textonly
DetailPrint "Installing Streaming Audio Manager 2..."
SetDetailsPrint listonly
SetOutPath "$INSTDIR"
File "..\Examples\license.txt"
File "..\Examples\SAMInstall.exe"
ExecWait '"$INSTDIR\SAMInstall.exe"'
Delete "$INSTDIR\SAMInstall.exe"
SectionEnd