# HG changeset patch # User Markus Mützel # Date 1637418860 -3600 # Node ID 9cd5425b033b08717c3c6df5b1d9301eb24ab93b # Parent b8e9589b77949879d1637867f133d6abf2214d48 octave-launch-firsttime: New launcher executable for starting Octave first time. * installer-files/octave-launch.c: Conditionally change to USERPROFILE before running Octave. * binary-dist-rules.mk(octave-launch-firsttime, installer-files/octave-launch-firsttime.exe): Add build rules for new launcher executable. (copy-windows-dist-files): Copy octave-launch-firsttime.exe to $(OCTAVE_DIST_DIR). diff -r b8e9589b7794 -r 9cd5425b033b binary-dist-rules.mk --- a/binary-dist-rules.mk Sat Nov 20 14:09:41 2021 +0100 +++ b/binary-dist-rules.mk Sat Nov 20 15:34:20 2021 +0100 @@ -26,6 +26,7 @@ TAR_H_OPTION := -h WINDOWS_BINARY_DIST_DEPS := \ octave-launch \ + octave-launch-firsttime \ win7appid \ blas_switch @@ -99,6 +100,13 @@ ## FIXME: We aren't using VPATH? installer-files/octave-launch.exe: $(TOP_DIR)/installer-files/octave-launch.c | installer-files/.dirstamp $(MXE_CC) $< -o $@ -Wl,--subsystem,windows -lshlwapi -municode -DUNICODE -D_UNICODE + +.PHONY: octave-launch-firsttime +octave-launch-firsttime: installer-files/octave-launch-firsttime.exe + +## FIXME: We aren't using VPATH? +installer-files/octave-launch-firsttime.exe: $(TOP_DIR)/installer-files/octave-launch.c | installer-files/.dirstamp + $(MXE_CC) $< -o $@ -Wl,--subsystem,windows -lshlwapi -municode -DUNICODE -D_UNICODE -DFIRST_TIME endif ifeq ($(MXE_WINDOWS_BUILD),yes) @@ -129,6 +137,7 @@ cp $(OCTAVE_DIST_DIR)$(OCTAVE_ADD_PATH)/bin/libblas.dll $(OCTAVE_DIST_DIR)$(OCTAVE_ADD_PATH)/bin/librefblas.dll echo " installing octave-launch.exe..." cp $(TOP_BUILD_DIR)/installer-files/octave-launch.exe $(OCTAVE_DIST_DIR)/ + cp $(TOP_BUILD_DIR)/installer-files/octave-launch-firsttime.exe $(OCTAVE_DIST_DIR)/ echo " octave.vbs..." cp $(TOP_DIR)/installer-files/octave.vbs $(OCTAVE_DIST_DIR)/ cp $(TOP_DIR)/installer-files/octave-firsttime.vbs $(OCTAVE_DIST_DIR)/ @@ -179,6 +188,7 @@ cp $(OCTAVE_DIST_DIR)/bin/libblas.dll $(OCTAVE_DIST_DIR)/bin/librefblas.dll echo " installing octave-launch.exe..." cp $(TOP_BUILD_DIR)/installer-files/octave-launch.exe $(OCTAVE_DIST_DIR)/ + cp $(TOP_BUILD_DIR)/installer-files/octave-launch-firsttime.exe $(OCTAVE_DIST_DIR)/ echo " octave.vbs..." cp $(TOP_DIR)/installer-files/octave.vbs $(OCTAVE_DIST_DIR)/ cp $(TOP_DIR)/installer-files/octave-firsttime.vbs $(OCTAVE_DIST_DIR)/ diff -r b8e9589b7794 -r 9cd5425b033b installer-files/octave-launch.c --- a/installer-files/octave-launch.c Sat Nov 20 14:09:41 2021 +0100 +++ b/installer-files/octave-launch.c Sat Nov 20 15:34:20 2021 +0100 @@ -246,6 +246,18 @@ detect that. */ } +#ifdef FIRST_TIME + { + /* change directory to USERPROFILE before starting Octave */ + wchar_t tmpbuff[PATH_SZ]; + nSize = GetEnvironmentVariableW (L"USERPROFILE", tmpbuff, PATH_SZ-1); + if (nSize) + StringCchCopyW (path, PATH_SZ, tmpbuff); + + SetCurrentDirectoryW (path); + } +#endif + /* set up process args and start it */ { STARTUPINFO si;