hello everyone,
I'm trying to create a simple installer that would let the user select an (exe) location, then grab a data folder out of that location, and copy it to my EXEDIR (together with a bunch of other files that are included in the installer, but I have that part working).
I'm a beginner, so try to make it as simple as you can - many thanks.
let user choose location and copy folder?
10 posts
It´s not hard to implement that. But you say that you have a part already working. Can you provide the script so we can find out the best way to integrate the function.
hint: page directory, copyfiles
hint: page directory, copyfiles
; Include some utility NSIS librariesas mentioned, it's just supposed to let the user point the installer to the location of his x.exe, grab a folder from the location, mix it up with what's included in the installer, and spit everything out into one folder in the EXEDIR.
!include "MUI.nsh"
!include "Library.nsh"
!include WordFunc.nsh
!include WinVer.nsh
!include LogicLib.nsh
!include nsDialogs.nsh
; Define which application and version this is
!define SHORT_APP_NAME "test tool"
!define APP_NAME "test"
!define VERSION "1.0"
!define EXE_NAME "x.exe"
;
; Define Variables
;
Name "${APP_NAME}"
!define /date DATE "%d_%b_%Y"
OutFile "Generated\${SHORT_APP_NAME}_${VERSION}_${date}.exe"
SetOverwrite on
AllowSkipFiles on
; Set up interface options.
!define MUI_WELCOMEFINISHPAGE_BITMAP "Welcome.bmp"
!define MUI_ABORTWARNING
;
; Define/display installation pages
;
!define MUI_WELCOMEPAGE_TEXT "Welcome to xtool.\r\n\r\nClick Next to continue."
!insertmacro MUI_PAGE_WELCOME
; Define/display more installation pages
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
; Language - MUST come after all MUI_PAGE inserts, and after MUI_WELCOMEFINISHPAGE_BITMAP.
!insertmacro MUI_LANGUAGE "English"
; Define branding elements
Icon "Install.ico"
BrandingText "${APP_NAME} Installer"
Caption "${APP_NAME} Installer"
;
; Move original \X\DATA
;
Section "-Initial Setup"
SetOutPath "$EXEDIR\X"
File /r "files\X\*"
; something that would allow the user to point at x.exe on his hdd and then grab the X\DATA folder from the same location and then copy it to the EXEDIR\X needs to go here.
SectionEnd
;
This should work for you. 🙂
; Include some utility NSIS libraries
!include "MUI.nsh"
!include "Library.nsh"
!include WordFunc.nsh
!include WinVer.nsh
!include LogicLib.nsh
!include nsDialogs.nsh
; Define which application and version this is
!define SHORT_APP_NAME "test tool"
!define APP_NAME "test"
!define VERSION "1.0"
!define EXE_NAME "x.exe"
;
; Define Variables
;
Name "${APP_NAME}"
!define /date DATE "%d_%b_%Y"
OutFile "Generated\${SHORT_APP_NAME}_${VERSION}_${date}.exe"
SetOverwrite on
AllowSkipFiles on
; Set up interface options.
!define MUI_WELCOMEFINISHPAGE_BITMAP "Welcome.bmp"
!define MUI_ABORTWARNING
;
; Define/display installation pages
;
!define MUI_WELCOMEPAGE_TEXT "Welcome to xtool.\r\n\r\nClick Next to continue."
!insertmacro MUI_PAGE_WELCOME
Var XDATA_Folder
!define MUI_DIRECTORYPAGE_VARIABLE $XDATA_Folder
!define MUI_DIRECTORYPAGE_TEXT_TOP "Text1"
!define MUI_DIRECTORYPAGE_TEXT_DESTINATION "Text2"
!insertmacro MUI_PAGE_DIRECTORY
; Define/display more installation pages
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
; Language - MUST come after all MUI_PAGE inserts, and after MUI_WELCOMEFINISHPAGE_BITMAP.
!insertmacro MUI_LANGUAGE "English"
; Define branding elements
Icon "Install.ico"
BrandingText "${APP_NAME} Installer"
Caption "${APP_NAME} Installer"
;
; Move original \X\DATA
;
Section "-Initial Setup"
SetOutPath "$EXEDIR\X"
File /r "files\X\*"
; something that would allow the user to point at x.exe on his hdd and then grab the X\DATA folder from the same location and then copy it to the EXEDIR\X needs to go here.
CopyFiles "$XDATA_Folder\*.*" "$EXEDIR\X\DATA"
SectionEnd
working nicely, thank you.
eh, not done yet - I need to completely disable space checks (the grabbed data can be on a read only media and the installer insists that it must have space there). tried to play around with dirLeave for a bit but was not able to get it working - any suggestions?
If you only have one directory page in your installer you can use "SpaceTexts none", if not you must manually hide the labels.
!include MUI2.nsh
#SpaceTexts none
var MySrcDir
!define MUI_DIRECTORYPAGE_VARIABLE $MySrcDir
!define MUI_DIRECTORYPAGE_VERIFYONLEAVE ; Do validation in the leave callback
!define MUI_PAGE_CUSTOMFUNCTION_SHOW mysrcdirpageshow
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE mysrcdirpageleave
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Function mysrcdirpageshow
ShowWindow $mui.DirectoryPage.SpaceRequired 0
ShowWindow $mui.DirectoryPage.SpaceAvailable 0
FunctionEnd
Function mysrcdirpageleave
${IfNot} ${FileExists} "$MySrcDir\Regedit.exe"
MessageBox mb_iconstop "Select the folder with Regedit.exe"
Abort
${EndIf}
FunctionEnd
jamming !define MUI_DIRECTORYPAGE_VERIFYONLEAVE ; Do validation in the leave callback right under Var XDATA_Folder has done the trick. SpaceTexts none right under !include MUI2.nsh has gotten rid of the text displaying the space, so mission accomplished.
thank you.
thank you.
Ah, you are using MUI v1, switch to MUI2.nsh or change the variables in the show callback to hwnd's you read from the .ini (You can inspect the .ini file for the page in %Temp%\*ns* ($PluginsDir\*.ini) when the page is active)Originally Posted by v47 View Postcouldn't make the rest work
no need, at the moment, everything works as it should, so unless some other issue pops out, all should be good. the simpler I can keep this, the better - I have very little experience in this area (not a coder, just a "make it work, somehow" guy).