Skip to content

Commit 2933012

Browse files
committed
Fixes in installer script for NSIS 3.10 update
The plugin ExecCmd is not supported and not working anymore. The replacement plugin is ExecDos. While the API of ExecDos looks similar to ExecCmd it behaves in a lot aspects differently. Also some documented functionality like "application output to log file" was not possible to get working. Environment variables as part of the command line are not supported. (Need to be resolved before) Thus, the method used now is where the plugin puts the output on the stack. As workaround for the piping the stack is written to a file. Then the second command is called in a separate call.
1 parent 05dd869 commit 2933012

File tree

1 file changed

+43
-9
lines changed

1 file changed

+43
-9
lines changed

tools/installer/installer.nsi

+43-9
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
!define IGOR9DEFPATH "$PROGRAMFILES64\WaveMetrics\Igor Pro 9 Folder"
4343
!define IGOR10DEFPATH "$PROGRAMFILES64\WaveMetrics\Igor Pro 10 Folder"
4444

45+
# Temp file for command execution output for ExecDos::Exec
46+
!define EXECDOSOUTPUT "ExecOutput.log"
47+
4548
#Unicode true
4649
SetCompressor /SOLID lzma
4750
!include "${NSISREQUEST}"
@@ -128,11 +131,42 @@ Var NSD_IF_CB4
128131
Quit
129132
!macroend
130133

131-
!macro FindProc result processName
132-
ExecCmd::exec "%SystemRoot%\System32\tasklist /NH /FI $\"IMAGENAME eq ${processName}$\" | %SystemRoot%\System32\find /I $\"${processName}$\""
133-
Pop $0 ; The handle for the process
134-
ExecCmd::wait $0
134+
!macro FindProc result processName uid
135+
ReadEnvStr $0 SYSTEMROOT
136+
Push "ExecDos::End"
137+
; In contradiction to the docs the two empty strings at the end are mandatory. Otherwise the stack gets cleared.
138+
; The logfile name (third string) is put on the stack before the command output.
139+
; I could not get the plugin to generate any logfile output by itself.
140+
; Stack:
141+
; <command output>
142+
; ...
143+
; <logfile name>
144+
; <Marker> if pushed before
145+
; I found no way that allows piping to a second application
146+
ExecDos::exec /NOUNLOAD /TOSTACK "$0\System32\tasklist.exe /NH /FI $\"IMAGENAME eq ${processName}$\"" "" ""
147+
Pop $0
148+
${if} $0 <> 0
149+
IfSilent +2
150+
MessageBox MB_OK|MB_ICONEXCLAMATION "Can not get current task list through tasklist.exe."
151+
Quit
152+
${EndIf}
153+
154+
ReadEnvStr $0 TEMP
155+
FileOpen $4 "$0\${EXECDOSOUTPUT}" w
156+
Loop_${uid}:
157+
Pop $1
158+
StrCmp $1 "ExecDos::End" LoopEnd_${uid}
159+
FileWrite $4 $1
160+
Goto Loop_${uid}
161+
LoopEnd_${uid}:
162+
FileClose $4
163+
164+
ReadEnvStr $0 SYSTEMROOT
165+
ReadEnvStr $1 TEMP
166+
ExecDos::exec /NOUNLOAD "$0\System32\find.exe /I $\"${processName}$\" $1\${EXECDOSOUTPUT}" "" ""
167+
135168
Pop ${result} ; The exit code
169+
Delete $1\${EXECDOSOUTPUT}
136170
!macroend
137171

138172
!macro CheckAllUninstalled
@@ -195,7 +229,7 @@ Var NSD_IF_CB4
195229
!macro WaitForProc ProcName
196230
!define WFPID ${__LINE__}
197231
WFUWaitUninstA_${WFPID}:
198-
!insertmacro FindProc $processFound "${ProcName}"
232+
!insertmacro FindProc $processFound "${ProcName}" ${__LINE__}
199233
IntCmp $processFound ${FindProc_NOT_FOUND} WFUEndWaitUninstA_${WFPID}
200234
Sleep 100
201235
Goto WFUWaitUninstA_${WFPID}
@@ -219,15 +253,15 @@ WFUEndWaitUninstA_${WFPID}:
219253
!macroend
220254

221255
!macro StopOnIgor32
222-
!insertmacro FindProc $processFound "Igor.exe"
256+
!insertmacro FindProc $processFound "Igor.exe" ${__LINE__}
223257
IntCmp $processFound ${FindProc_NOT_FOUND} +4
224258
IfSilent +2
225259
MessageBox MB_OK|MB_ICONEXCLAMATION "Igor Pro is running. Please close it first" /SD IDOK
226260
Quit
227261
!macroend
228262

229263
!macro StopOnIgor64
230-
!insertmacro FindProc $processFound "Igor64.exe"
264+
!insertmacro FindProc $processFound "Igor64.exe" ${__LINE__}
231265
IntCmp $processFound ${FindProc_NOT_FOUND} +4
232266
IfSilent +2
233267
MessageBox MB_OK|MB_ICONEXCLAMATION "Igor Pro (64-bit) is running. Please close it first" /SD IDOK
@@ -833,9 +867,9 @@ ReadLoop:
833867
FileRead $FILEHANDLE $LINESTR
834868
IfErrors +1 +2
835869
Goto EndReadLoop
836-
ExecCmd::exec "cmd.exe /Cdel $\"$LINESTR$\""
870+
ExecDos::exec /NOUNLOAD "cmd.exe /Cdel $\"$LINESTR$\"" "" ""
837871
Pop $0
838-
ExecCmd::wait $0
872+
ExecDos::wait $0
839873
Pop $0
840874
Goto ReadLoop
841875
EndReadLoop:

0 commit comments

Comments
 (0)