Jar to exe using NSIS - jar

so I seeking for a program (which is free) that will allow me to make from jar to exe with wrapping JRE also... til now I used Launch4J and I tried out others also but I found NSIS which is much more powerful and i think will fit what I'm looking for, but I'm having problems with defining CLASSPATH and CLASS.
Here's the code:
Name "Tool"
Caption "Internal"
Icon "UIT.ico"
OutFile "Tool.exe"
VIAddVersionKey "ProductName" "Tool"
VIAddVersionKey "Comments" "Internal"
VIAddVersionKey "CompanyName" ""
VIAddVersionKey "LegalTrademarks" ""
VIAddVersionKey "LegalCopyright" ""
VIAddVersionKey "FileDescription" "Tool"
VIAddVersionKey "FileVersion" "3.0.1934"
VIProductVersion 3.0.1934"
!define CLASSPATH "ApplicationTool.jar"
!define CLASS "v3build1934"
!define PRODUCT_NAME "Tool"
; Definitions for Java 8.0
!define JRE_VERSION "8.0"
!define JRE_URL "http://javadl.sun.com/webapps/download/AutoDL?BundleId=24936&/jre-6u10-windows-i586-p.exe"
;!define JRE_VERSION "8.0"
;!define JRE_URL "http://javadl.sun.com/webapps/download/AutoDL?BundleId=22933&/jre-1_5_0_16-windows-i586-p.exe"
; use javaw.exe to avoid dosbox.
; use java.exe to keep stdout/stderr
!define JAVAEXE "javaw.exe"
RequestExecutionLevel user
SilentInstall silent
AutoCloseWindow true
ShowInstDetails nevershow
!include "FileFunc.nsh"
!insertmacro GetFileVersion
!insertmacro GetParameters
!include "WordFunc.nsh"
!insertmacro VersionCompare
!include "UAC.nsh"
Section ""
Call GetJRE
Pop $R0
; change for your purpose (-jar etc.)
${GetParameters} $1
StrCpy $0 '"$R0" -classpath "${CLASSPATH}" ${CLASS} $1'
SetOutPath $EXEDIR
Exec $0
SectionEnd
; returns the full path of a valid java.exe
; looks in:
; 1 - .\jre directory (JRE Installed with application)
; 2 - JAVA_HOME environment variable
; 3 - the registry
; 4 - hopes it is in current dir or PATH
Function GetJRE
Push $R0
Push $R1
Push $2
; 1) Check local JRE
CheckLocal:
ClearErrors
StrCpy $R0 "$EXEDIR\pkg\bin\${JAVAEXE}"
IfFileExists $R0 JreFound
; 2) Check for JAVA_HOME
CheckJavaHome:
ClearErrors
ReadEnvStr $R0 "JAVA_HOME"
StrCpy $R0 "$R0\bin\${JAVAEXE}"
IfErrors CheckRegistry
IfFileExists $R0 0 CheckRegistry
Call CheckJREVersion
IfErrors CheckRegistry JreFound
; 3) Check for registry
CheckRegistry:
ClearErrors
ReadRegStr $R1 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" "CurrentVersion"
ReadRegStr $R0 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment\$R1" "JavaHome"
StrCpy $R0 "$R0\bin\${JAVAEXE}"
IfErrors DownloadJRE
IfFileExists $R0 0 DownloadJRE
Call CheckJREVersion
IfErrors DownloadJRE JreFound
DownloadJRE:
Call ElevateToAdmin
MessageBox MB_ICONINFORMATION "${PRODUCT_NAME} uses Java Runtime Environment ${JRE_VERSION}, it will now be downloaded and installed."
StrCpy $2 "$TEMP\Java Runtime Environment.exe"
nsisdl::download /TIMEOUT=30000 ${JRE_URL} $2
Pop $R0 ;Get the return value
StrCmp $R0 "success" +3
MessageBox MB_ICONSTOP "Download failed: $R0"
Abort
ExecWait $2
Delete $2
ReadRegStr $R1 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" "CurrentVersion"
ReadRegStr $R0 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment\$R1" "JavaHome"
StrCpy $R0 "$R0\bin\${JAVAEXE}"
IfFileExists $R0 0 GoodLuck
Call CheckJREVersion
IfErrors GoodLuck JreFound
; 4) wishing you good luck
GoodLuck:
StrCpy $R0 "${JAVAEXE}"
; MessageBox MB_ICONSTOP "Cannot find appropriate Java Runtime Environment."
; Abort
JreFound:
Pop $2
Pop $R1
Exch $R0
FunctionEnd
; Pass the "javaw.exe" path by $R0
Function CheckJREVersion
Push $R1
; Get the file version of javaw.exe
${GetFileVersion} $R0 $R1
${VersionCompare} ${JRE_VERSION} $R1 $R1
; Check whether $R1 != "1"
ClearErrors
StrCmp $R1 "1" 0 CheckDone
SetErrors
CheckDone:
Pop $R1
FunctionEnd
; Attempt to give the UAC plug-in a user process and an admin process.
Function ElevateToAdmin
UAC_Elevate:
!insertmacro UAC_RunElevated
StrCmp 1223 $0 UAC_ElevationAborted ; UAC dialog aborted by user?
StrCmp 0 $0 0 UAC_Err ; Error?
StrCmp 1 $1 0 UAC_Success ;Are we the real deal or just the wrapper?
Quit
UAC_ElevationAborted:
# elevation was aborted, run as normal?
MessageBox MB_ICONSTOP "This installer requires admin access, aborting!"
Abort
UAC_Err:
MessageBox MB_ICONSTOP "Unable to elevate, error $0"
Abort
UAC_Success:
StrCmp 1 $3 +4 ;Admin?
StrCmp 3 $1 0 UAC_ElevationAborted ;Try again?
MessageBox MB_ICONSTOP "This installer requires admin access, try again"
goto UAC_Elevate
FunctionEnd
What do i need to put in those 2 or should I move the script somewhere else for example where the netbeans project is ???

You can set environment variables for the NSIS process and child processes by calling SetEnvironmentVariable:
System::Call 'Kernel32::SetEnvironmentVariable(t "CLASSPATH", t "c:\some\path\you\got\from\the\registry")'

Related

Why file being created in electron-builder install process is being removed from the installation user folder?

While adding a script to run in the process of installation, I see the file I'm writing into being deleted or removed from the installation directory. Why?
my vue.config.js file:
pluginOptions: {
electronBuilder: {
builderOptions: {
appId: 'test.com',
win: {
"target": ["nsis"]
},
"nsis": {
"include": "build/installer.nsh",
"oneClick": false,
"allowToChangeInstallationDirectory": true
}
}
}
}
my script create new file and write inside user name/password:
my installer.nsh file:
!include nsDialogs.nsh
!include LogicLib.nsh
XPStyle on
Var Dialog
Var UserLabel
Var UserText
Var UserState
Var PassLabel
Var PassText
Var PassState
Page custom nsDialogsPage nsDialogsPageLeave
Function nsDialogsPage
nsDialogs::Create 1018
Pop $Dialog
${If} $Dialog == error
Abort
${EndIf}
${NSD_CreateLabel} 0 0 100% 12u "Your Username:"
Pop $UserLabel
${NSD_CreateText} 0 13u 100% 12u $UserState
Pop $UserText
${NSD_CreateLabel} 0 39u 100% 12u "Your Password:"
Pop $PassLabel
${NSD_CreatePassword} 0 52u 100% 12u $PassState
Pop $PassText
nsDialogs::Show
FunctionEnd
Function nsDialogsPageLeave
${NSD_GetText} $UserText $UserState
${NSD_GetText} $PassText $PassState
${If} $UserState == ""
MessageBox MB_OK "Username is missing."
Abort
${EndIf}
${If} $PassState == ""
MessageBox MB_OK "Password is missing."
Abort
${EndIf}
StrCpy $1 $UserState
StrCpy $2 $PassState
FunctionEnd
Section
SetOutPath "$INSTDIR\myfolder"
FileOpen $9 $INSTDIR\myfolder\credentials.txt w
FileWrite $9 "$1 $2"
FileClose $9
SectionEnd
While running the setup.exe file I can see it creates "myfolder" and also creates the "credentials.txt" file and update it, but when the process ends - the folder stays empty. The file was removed. Why? What I'm missing here?

How to get locale-independent modified time and creation time of a file in batch?

With batch variable/parameter expansion like %~t1 one can get a timestamp of a file.
I would like to set the year of the file to another variable would like to support multiple locales.
How can you get a file's datetime, independent of locale and regional settings? No powershell please.
I'll post few options
1)First one is with wmic (not available for XP home edition) (LastModified can be changed with CreationDate or LastAccessed )
#echo off
set file_loc=.\temp_file
for %%# in ("%file_loc%") do set file_loc=%%~dpfnx#
set file_loc=%file_loc:\=\\%
for /f "delims=." %%t in ('"WMIC DATAFILE WHERE name="%file_loc%" get LastModified /format:value"') do (
for /f %%$ in ("%%t") do if "%%$" neq "" set %%$
)
echo %LastModified%
echo year : %LastModified:~0,4%
echo month : %LastModified:~4,2%
echo day : %LastModified:~6,2%
2). Jscript/.bat hybrid (DateLastModified can be changed to DateCreated or DateLastAccessed .Time format can be changed to whatever you want ):
#if (#X)==(#Y) #end /****** jscript comment ******
#echo off
set file_loc=.\temp_file
for %%# in ("%file_loc%") do set file_loc=%%~dpfnx#
::set file_loc=%file_loc:\=\\%
cscript //E:JScript //nologo "%~f0" "%file_loc%"
exit /b 0
****** end of jscript comment ******/
var file_loc = WScript.Arguments.Item(0);
var fso = new ActiveXObject("Scripting.FileSystemObject");
var the_file=fso.GetFile(file_loc);
var the_date= new Date(the_file.DateLastModified);
WScript.Echo(the_date.getFullYear());
WScript.Echo(the_date.getMonth());
WScript.Echo(the_date.getUTCDate());
3) selfcompiled jscript.net/bat hybrid (GetLastWriteTime can be changed to GetLastAccessTime or GetCreationTime . Time format can be changed) :
#if (#X)==(#Y) #end /****** silent line that start jscript comment ******
#echo off
::::::::::::::::::::::::::::::::::::
::: compile the script ::::
::::::::::::::::::::::::::::::::::::
setlocal
if exist "%~n0.exe" goto :skip_compilation
set "frm=%SystemRoot%\Microsoft.NET\Framework\"
:: searching the latest installed .net framework
for /f "tokens=* delims=" %%v in ('dir /b /s /a:d /o:-n "%SystemRoot%\Microsoft.NET\Framework\v*"') do (
if exist "%%v\jsc.exe" (
rem :: the javascript.net compiler
set "jsc=%%~dpsnfxv\jsc.exe"
goto :break_loop
)
)
echo jsc.exe not found && exit /b 0
:break_loop
call %jsc% /nologo /out:"%~n0.exe" "%~dpsfnx0"
::::::::::::::::::::::::::::::::::::
::: end of compilation ::::
::::::::::::::::::::::::::::::::::::
:skip_compilation
set file_loc=.\temp_file
for %%# in ("%file_loc%") do set file_loc=%%~dpfnx#
"%~n0.exe" "%file_loc%"
exit /b 0
****** end of jscript comment ******/
import System;
import System.IO;
var arguments:String[] = Environment.GetCommandLineArgs();
var the_file=arguments[1];
var last_modified=File.GetLastWriteTime(the_file);
Console.WriteLine(last_modified.ToString("yyyy-MM-dd"));
4). robocopy - with this you can get only last modified date (with other methods you can get all time attributes).As time stamps in robocopy are always YYYY/MM/DD HH:mm:SS this can be used...
#ECHO OFF
set file_loc=.\temp_file
for %%# in ("%file_loc%") do set file_dir=%%~dp#
for %%# in ("%file_loc%") do set file_name=%%~nx#
pushd %file_dir%
for /f "tokens=1,2" %%a in ('robocopy "." "%temp%" /l /fat /ts /LEV:1 /NP /NC /NS /NJS /NJH^|findstr /i /e /c:"%file_name%"') do (
echo %%a %%b
)
popd
EDIT Here are ready to use parametrized scripts using all the listed methods:
fileModifiedTime.bat - gets last modified time of file with settings independent format.Based on robocopy
fileTimes.bat - gets file time stamps with WMIC
dirTimes.bat - gets directory time stamps with WMIC
fileTimesJS.bat - file time stamps with jscript
dirTimesJS.bat - directory time stamps with jscript
fileTimesNET.bat - file time stamps with .NET
dirTimesNET.bat - dir time stamps with .NET

Copy a directory over http within a windows batch file

I need a command to use in a batch file, which copies the contents of a remote directory to a local directory over http.
For example to copy folder http ://path//folder to C:\folder
I need to do this without installing any additional tools.
Thanks in advance!
There's no standard way for an http server to list accessible directories.
For example I took http://unomoralez.com/content/files/catalog2/source/ as one of the common ways to list directory with http. Your site could look different though but there's no way for me tho know... (ther's a temp list2.txt file - you can remark its deletion to check the format of directory page and tell me if its not working. IF it is IIS could look like this: http://live.sysinternals.com/tools/)
the script downloads all content into .\download_dir (not recursive download) :
#if (#X)==(#Y) #end /****** jscript comment ******
#echo off
::::::::::::::::::::::::::::::::::::
::: compile the script ::::
::::::::::::::::::::::::::::::::::::
setlocal
if exist simpledownloader.exe goto :skip_compilation
set "frm=%SystemRoot%\Microsoft.NET\Framework\"
:: searching the latest installed .net framework
for /f "tokens=* delims=" %%v in ('dir /b /s /a:d /o:-n "%SystemRoot%\Microsoft.NET\Framework\v*"') do (
if exist "%%v\jsc.exe" (
rem :: the javascript.net compiler
set "jsc=%%~dpsnfxv\jsc.exe"
goto :break_loop
)
)
echo jsc.exe not found && exit /b 0
:break_loop
call %jsc% /nologo /out:"simpledownloader.exe" "%~dpsfnx0"
::::::::::::::::::::::::::::::::::::
::: end of compilation ::::
::::::::::::::::::::::::::::::::::::
:skip_compilation
:: download the file
:::::::::::::::::::::::::::::::::::::::::
::::just change the link and the file::::
:::::::::::::::::::::::::::::::::::::::::
::!!!!!!!!!!!!!!!!!!!!!!!!!:::
simpledownloader.exe "http://unomoralez.com/content/files/catalog2/source/" "list2.txt"
md download_dir >nul 2>&1
for /f "skip=1 tokens=4 delims=>< " %%a in ('type list2.txt^| find /i "href" ') do (
simpledownloader.exe "http://unomoralez.com/content/files/catalog2/source/%%a" .\download_dir\%%a
)
del /q /f list2.txt
exit /b 0
****** end of jscript comment ******/
import System;
var arguments:String[] = Environment.GetCommandLineArgs();
var webClient:System.Net.WebClient = new System.Net.WebClient();
print("Downloading " + arguments[1] + " to " + arguments[2]);
try {
webClient.DownloadFile(arguments[1], arguments[2]);
} catch (e) {
Console.BackgroundColor = ConsoleColor.Green;
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("\n\nProblem with downloading " + arguments[1] + " to " + arguments[2] + "Check if the internet address is valid");
Console.ResetColor();
Environment.Exit(5);
}
As you have powershell you also have .net so this code will be executed without problems for you.
This was more or less a code that I already had but you can also check this -> https://code.google.com/p/curlie/ if you are familiar with cURL and create a hybrid jscript/.bat file.

Windows Overwriting console

I was downloading MingW, and noticed that for a time the installer spawns a console window and downloads files. The intersting part is that it somehow creates download bars in the console window and overwrites the precentage number. I was wondering how this is accomplished?
NOTE:I am almost 100% sure the console is not writing '\n' out and is in fact overwriting the console.
I see Google was broken.
http://ss64.org/viewtopic.php?id=1499
The code:
#echo off
:: *****************************************************************************
:: * Script Name: DetectMSI_v1.0.cmd *
:: * Author: Gustaaf von Pickartz. *
:: * Date Created: 19th July, 2012. *
:: * Internal Version: Version 1.0 *
:: * ------------------------------------------------------------------------- *
:: * Notice: *
:: * This program is provided as is and for fair use distribution. *
:: * Give credit where credit is due to the author in your own script. *
:: * ------------------------------------------------------------------------- *
:: * Purpose: *
:: * Detect current active MSIEXEC instances using a function for repeatable *
:: * calls within a script and display a progress bar... *
:: * ------------------------------------------------------------------------- *
:: * Updated by: ------- *
:: * Date: 19-07-2012 *
:: * Change1: "Initial script version." *
:: * ------------------------------------------------------------------------- *
:: *****************************************************************************
SETLOCAL ENABLEDELAYEDEXPANSION
SET PRG0=[* ]
SET PRG1=[#* ]
SET PRG2=[##* ]
SET PRG3=[###* ]
SET PRG4=[####* ]
SET PRG5=[#####* ]
SET PRG6=[######* ]
SET PRG7=[#######* ]
SET PRG8=[########* ]
SET PRG9=[#########*]
SET PRG10=[##########]
:: Please note there are special ASCII insertions in the SET BKSPC= declaration below. 80x backspace characters are inserted. ASCII Value 08=[BS]
:: Be sure to verify they are still there when you cut and paste from the web with your text editor (Notepad++ or PsPad). Insert them if missing, otherwise this script will not work...
SET BKSPC=
:Begin_Main
:: For the sake of the demonstration, start MSIEXEC minimized.
START /MIN MSIEXEC
:: Call our function.
CALL :Fnc_Msi
:: Waste a little time...
PING -n 7 localhost >nul
ECHO Exited the FIRST MSIEXEC detection function and progress bar demo.
ECHO.
ECHO.
ECHO A function can't be a function if it cannot be re-used right?
:: For the sake of the demonstration, start MSIEXEC minimized.
START /MIN MSIEXEC
:: Call our function.
CALL :Fnc_Msi
ECHO Exited the SECOND MSIEXEC detection function and progress bar demo.
echo.
echo.
pause
GOTO :EOF
:: -----------------------------------------------------------------------------
:: Below code is setup to run as a Function to be called anywhere in your script.
:: It will wait 10 loops at 7 sec intervals anytime it is called. Primarily written to detect active MSI installers.
:: The Menu counter and Progress bar is in the function for fun.
::
:: Usage: CALL :Fnc_Msi
2
:Fnc_Msi
CALL ECHO [.....] %%date%% %%time%% Testing for active MSI instances.
:catchit
IF NOT DEFINED CatchMSI SET CatchMSI=0
IF %CatchMSI% EQU 5 (
ECHO Waited 5 loops {15sec.} to detect MSI activities. Now resuming further MSI evaluation.
goto evalmsi
)
FOR /F "TOKENS=2* DELIMS=:" %%I IN ('TASKLIST /V /FI "IMAGENAME EQ MSIEXEC.EXE" /FO LIST 2^>NUL ^|FIND /I /V "N/A" ^|FIND /I "WINDOW TITLE:"') DO (SET MSI=%%I)
IF DEFINED MSI SET MSI_APP=%MSI:~1%
IF DEFINED MSI_APP goto msi_active
>NUL PING -n 3 localhost
SET /A CatchMSI+=1
goto :catchit
:evalmsi
IF NOT DEFINED MSI_APP (
ECHO [OKAY.] No active MSIEXEC installer running. It is safe to continue.
SET CatchMSI=
SET MSI_APP=
SET CNT=
SET COUNT=
SET TIC=
GOTO :EOF
)
:msi_active
SET CNT=0
ECHO [ALERT] Installer "%MSI_APP%" is active. Waiting maximum 10 counts.
:loop
IF NOT DEFINED COUNT SET COUNT=0
IF %COUNT% LEQ 9 (SET TIC=0%COUNT%) ELSE (SET TIC=%COUNT%)
IF %count% EQU 10 (
<NUL (SET/P Z=[%tic%/10] PROGRESS: !PRG%CNT%!)
:: Feel free to adjust the PING -n 3 value to say 30sec waits.
>NUL PING -n 3 localhost
TASKKILL /F /FI "WINDOWTITLE eq %MSI_APP%*" >>myprogress.log
<NUL SET/P Z=%BKSPC%
SET MSI_APP=
SET CatchMSI=
SET MSI_APP=
SET CNT=
SET COUNT=
SET TIC=
GOTO :EOF
)
<NUL (SET/P Z=[%tic%/10] PROGRESS: !PRG%CNT%!)
:: Feel free to adjust the PING -n 3 value to say 30sec waits.
>NUL PING -n 3 localhost
<NUL SET/P Z=%BKSPC%
:: Here we write to a log file and call tasklist.exe to do interval checks on the MSIEXEC status.
:: Demonstrated is that the progress bar is not affected when code is run in the loop.
:: Do keep in mind to "suppress to >nul 2>nul" any output that may disrupt the progress bar activty.
ECHO [%tic%/10] Waiting for "%MSI_APP%" to complete. >>myprogress.log
TASKLIST.EXE /V | FIND /I "%MSI_APP%">NUL 2>NUL
IF %ERRORLEVEL% EQU 1 (
>NUL PING -n 7 localhost
SET CatchMSI=
SET MSI_APP=
SET CNT=
SET COUNT=
SET TIC=
GOTO :EOF
)
SET /A CNT+=1
SET /A COUNT+=1
goto loop
GOTO :EOF
:: -----------------------------------------------------------------------------
Credit is obviously due to the original author.

fill directory textbox on button click in MUI NSI Installer , using ButtonEvent plug-in

i have added custom button using Resource Hacker on the MUI Directory Page of the installer, now i want that when the button is clicked then the Default Textbox where the user enters the InstallDir (the path where the application is installed), is filled with some specified text. please help me with the code?
I am using ButtonEvent plug-in, but i don't know what code to write in the event handler. Currently am just displaying a message box when the button is clicked to ensure that the event is working.
Please help.
!define IDC_BUTTON_SETPATH 1200 (1200 is the ID OF THE BUTTON ADDED from Resource hacker)
;Pages
!insertmacro MUI_PAGE_WELCOME
!define MUI_PAGE_CUSTOMFUNCTION_SHOW DirectoryShow
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE DirectoryLeave
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
;--------------------------------
Function buttonclicked
MessageBox MB_OK|MB_ICONEXCLAMATION "You Clicked Me "
Abort
FunctionEnd
# Occurs on installer UI initialization.
Function myGuiInit
# Create event handler for our parent window button.
GetFunctionAddress $R3 buttonclicked
ButtonEvent::AddEventHandler ${IDC_BUTTON_SETPATH} $R3
FunctionEnd
------------------------NEW EDITED PART-- CODE FOR THREE CUSTOM BUTTONS-------------------
!include MUI2.nsh
; --------------------------------------------------
!define IDC_BUTTON_CDRIVEPATH 1200
!define IDC_BUTTON_DDRIVEPATH 1201
!define IDC_BUTTON_EDRIVEPATH 1202
; --------------------------------------------------
# The event handler for our parent button is added in MyGUIInit.
!define MUI_CUSTOMFUNCTION_GUIINIT myGuiInit
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\pksicon.bmp" ; optional
!define MUI_WELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\pksleftimage.bmp" ;
;--------------------------------
XPStyle on
;Interface Settings
!define MUI_ABORTWARNING
;--------------------------------
;Pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\licensefile.txt"
!define MUI_PAGE_CUSTOMFUNCTION_SHOW DirectoryShow
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
; --------------------------------------------------
; Languages.
!insertmacro MUI_LANGUAGE English
; --------------------------------------------------
!macro SetDirPageInstallDir text
!if "${MUI_SYSVERSION}" < "2.0"
Push $0
FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $0 $0 0x3FB
SendMessage $0 ${WM_SETTEXT} 0 "STR:${text}"
Pop $0
!else
SendMessage $mui.DirectoryPage.Directory ${WM_SETTEXT} 0 "STR:${text}"
!endif
!macroend
# Called when the CDRIVEPATH button is pressed.
Function CDRIVEPATH
MessageBox MB_OK|MB_ICONEXCLAMATION "The Software will be installed in : C:\ "
;In buttonclicked handler
!insertmacro SetDirPageInstallDir "C:\"
FunctionEnd
;--------------------------------
Function DDRIVEPATH
MessageBox MB_OK|MB_ICONEXCLAMATION "The Software will be installed in : D:\ "
;In buttonclicked handler
!insertmacro SetDirPageInstallDir "D:\"
FunctionEnd
;--------------------------------
Function EDRIVEPATH
MessageBox MB_OK|MB_ICONEXCLAMATION "The Software will be installed in : E:\ "
;In buttonclicked handler
!insertmacro SetDirPageInstallDir "E:\"
FunctionEnd
;--------------------------------
InstallDir $INSTDIR
# Occurs on installer UI initialization.
Function myGuiInit
# Create event handler for our parent window button.
GetFunctionAddress $R0 CDRIVEPATH
ButtonEvent::AddEventHandler ${IDC_BUTTON_CDRIVEPATH} $R0
; GetFunctionAddress $R1 EDRIVEPATH **-----this line causes error**
; ButtonEvent::AddEventHandler ${IDC_BUTTON_DDRIVEPATH} $R1 -----this line causes error
; GetFunctionAddress $R2 EDRIVEPATH **-----this line causes error**
; ButtonEvent::AddEventHandler ${IDC_BUTTON_EDRIVEPATH} $R2 -----this line causes error
FunctionEnd
;------------------------------------------------
# Occurs on Directory page show.
Function DirectoryShow
# Create event handler for our Directory page button. /NOTIFY makes
# the button move to the next page when clicked.
ButtonEvent::AddEventHandler ${IDC_BUTTON_CDRIVEPATH}
ButtonEvent::AddEventHandler ${IDC_BUTTON_DDRIVEPATH}
ButtonEvent::AddEventHandler ${IDC_BUTTON_EDRIVEPATH}
# Disable next button.
GetDlgItem $R0 $HWNDPARENT 1
EnableWindow $R0 0
FunctionEnd
; --------------------------------------------------
;General
;Name and file
Name NEW_FILL_TEXTBOX_BUTTONCLICK
OutFile NEW_FILL_TEXTBOX_BUTTONCLICK.exe
Section
DetailPrint "SUCCESSFULLY INSTALLED"
SectionEnd
You did not say which version of the MUI you are using, this macro should handle both...
!macro SetDirPageInstallDir text
!if "${MUI_SYSVERSION}" < "2.0"
Push $0
FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $0 $0 0x3FB
SendMessage $0 ${WM_SETTEXT} 0 "STR:${text}"
Pop $0
!else
SendMessage $mui.DirectoryPage.Directory ${WM_SETTEXT} 0 "STR:${text}"
!endif
!macroend
;In buttonclicked handler
!insertmacro SetDirPageInstallDir "$programfiles\Hello World"

Resources