45
45
# Temp file for command execution output for ExecDos::Exec
46
46
!define EXECDOSOUTPUT " ExecOutput.log"
47
47
48
+ # Return codes
49
+ !define ERROR_INSTALLER_ALREADY_RUNNING 1
50
+ !define ERROR_UNINSTALLER_ALREADY_RUNNING 2
51
+ !define ERROR_CANNOT_GET_TASKLIST 3
52
+ !define ERROR_ADMIN_INSTALLATION_PRESENT 4
53
+ !define ERROR_IGORPRO_IS_RUNNING 5
54
+ !define ERROR_IGORPRO64_IS_RUNNING 6
55
+ !define ERROR_64BIT_OS_REQUIRED 7
56
+ !define ERROR_ADMIN_REQUIRED 8
57
+ !define ERROR_MIES_ALREADY_INSTALLED 9
58
+ !define ERROR_NO_IGOR9_PATH 10
59
+ !define ERROR_NO_IGOR10_PATH 11
60
+ !define ERROR_CANNOT_CREATE_UNINSTALL_FILELIST 12
61
+ !define ERROR_CANNOT_DISABLE_ASLR 13
62
+ !define ERROR_CANNOT_FIX_OFFICE365 14
63
+ !define ERROR_CANNOT_CREATE_INSTALLCONFIG 15
64
+ !define ERROR_ELEVATION_REQUIRED 740
65
+
48
66
# Unicode true
49
67
SetCompressor /SOLID lzma
50
68
!include " ${NSISREQUEST}"
@@ -113,22 +131,29 @@ Var NSD_IF_CB4
113
131
114
132
!include " browsefolder.nsh"
115
133
116
- !macro PreventMultipleInstaller
134
+ !macro QuitWithCode code
135
+ SetErrorLevel code
136
+ Quit
137
+ !macroend
138
+
139
+ !macro PreventMultipleInstaller uid
117
140
System::Call ' kernel32::CreateMutex(p 0, i 0, t "MIESINSTALLMutex") p .r1 ?e'
118
141
Pop $R0
119
- StrCmp $R0 0 + 4
142
+ StrCmp $R0 0 MacroEnd_ ${uid}
120
143
IfSilent +2
121
144
MessageBox MB_OK |MB_ICONEXCLAMATION " The installer is already running."
122
- Quit
145
+ !insertmacro QuitWithCode ERROR_INSTALLER_ALREADY_RUNNING
146
+ MacroEnd_${uid} :
123
147
!macroend
124
148
125
- !macro PreventMultipleUninstaller
149
+ !macro PreventMultipleUninstaller uid
126
150
System::Call ' kernel32::CreateMutex(p 0, i 0, t "MIESUNINSTALLMutex") p .r1 ?e'
127
151
Pop $R0
128
- StrCmp $R0 0 + 4
152
+ StrCmp $R0 0 MacroEnd_ ${uid}
129
153
IfSilent +2
130
154
MessageBox MB_OK |MB_ICONEXCLAMATION " The uninstaller is already running."
131
- Quit
155
+ !insertmacro QuitWithCode ERROR_UNINSTALLER_ALREADY_RUNNING
156
+ MacroEnd_${uid} :
132
157
!macroend
133
158
134
159
!macro FindProc result processName uid
@@ -148,7 +173,7 @@ Var NSD_IF_CB4
148
173
${if} $0 <> 0
149
174
IfSilent +2
150
175
MessageBox MB_OK |MB_ICONEXCLAMATION " Can not get current task list through tasklist.exe."
151
- Quit
176
+ !insertmacro QuitWithCode ERROR_CANNOT_GET_TASKLIST
152
177
${EndIf}
153
178
154
179
ReadEnvStr $0 TEMP
@@ -169,7 +194,7 @@ Var NSD_IF_CB4
169
194
Delete $1 \${EXECDOSOUTPUT}
170
195
!macroend
171
196
172
- !macro CheckAllUninstalled
197
+ !macro CheckAllUninstalled uid
173
198
StrCpy $2 " 0"
174
199
ReadRegStr $0 HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" " DisplayName"
175
200
StrLen $1 $0
@@ -186,10 +211,11 @@ Var NSD_IF_CB4
186
211
IfFileExists " ${USERINSTDIR}\uninstall.exe" 0 +2
187
212
StrCpy $2 " 1"
188
213
189
- IntCmp $2 0 + 4
214
+ IntCmp $2 0 MacroEnd_ ${uid}
190
215
ifSilent +2
191
216
MessageBox MB_OK |MB_ICONSTOP " There is a already a installation of MIES present that was installed with administrative privileges. Uninstallation requires administrative privileges as well and can not be done with your current rights. Please contact an administrator to uninstall MIES through Add/Remove Programs first."
192
- Quit
217
+ !insertmacro QuitWithCode ERROR_ADMIN_INSTALLATION_PRESENT
218
+ MacroEnd_${uid} :
193
219
!macroend
194
220
195
221
!macro UninstallAttemptAdmin
@@ -255,20 +281,22 @@ WFUEndWaitUninstA_${WFPID}:
255
281
${EndIf}
256
282
!macroend
257
283
258
- !macro StopOnIgor32
284
+ !macro StopOnIgor32 uid
259
285
!insertmacro FindProc $processFound " Igor.exe" ${__LINE__}
260
- IntCmp $processFound ${FindProc_NOT_FOUND} + 4
286
+ IntCmp $processFound ${FindProc_NOT_FOUND} MacroEnd_ ${uid}
261
287
IfSilent +2
262
288
MessageBox MB_OK |MB_ICONEXCLAMATION " Igor Pro is running. Please close it first" /SD IDOK
263
- Quit
289
+ !insertmacro QuitWithCode ERROR_IGORPRO_IS_RUNNING
290
+ MacroEnd_${uid} :
264
291
!macroend
265
292
266
- !macro StopOnIgor64
293
+ !macro StopOnIgor64 uid
267
294
!insertmacro FindProc $processFound " Igor64.exe" ${__LINE__}
268
- IntCmp $processFound ${FindProc_NOT_FOUND} + 4
295
+ IntCmp $processFound ${FindProc_NOT_FOUND} MacroEnd_ ${uid}
269
296
IfSilent +2
270
297
MessageBox MB_OK |MB_ICONEXCLAMATION " Igor Pro (64-bit) is running. Please close it first" /SD IDOK
271
- Quit
298
+ !insertmacro QuitWithCode ERROR_IGORPRO64_IS_RUNNING
299
+ MacroEnd_${uid} :
272
300
!macroend
273
301
274
302
!macro SetInstallPath
@@ -467,7 +495,7 @@ function .onInit
467
495
${IfNot} ${RunningX64}
468
496
IfSilent +2
469
497
MessageBox MB_OK |MB_ICONEXCLAMATION " Aborting: MIES requires a 64-bit Windows OS."
470
- Quit
498
+ !insertmacro QuitWithCode ERROR_64BIT_OS_REQUIRED
471
499
${EndIf}
472
500
473
501
ClearErrors
@@ -497,7 +525,7 @@ function .onInit
497
525
QuitCantAlluser:
498
526
IfSilent +2
499
527
MessageBox MB_OK |MB_ICONEXCLAMATION " Aborting: You need to administrator privileges for /ALLUSER installation."
500
- Quit
528
+ !insertmacro QuitWithCode ERROR_ADMIN_REQUIRED
501
529
${EndIf}
502
530
503
531
CheckIgorPaths:
@@ -554,15 +582,15 @@ IGOR10CheckEnd:
554
582
${If} ${Errors}
555
583
# normal installation
556
584
557
- !insertmacro PreventMultipleInstaller
558
- !insertmacro StopOnIgor32
559
- !insertmacro StopOnIgor64
585
+ !insertmacro PreventMultipleInstaller ${__LINE__}
586
+ !insertmacro StopOnIgor32 ${__LINE__}
587
+ !insertmacro StopOnIgor64 ${__LINE__}
560
588
IntCmp $ISADMIN 0 SkipAdminUninstall
561
589
!insertmacro UninstallAttemptAdmin
562
590
SkipAdminUninstall:
563
591
!insertmacro UninstallAttemptUser
564
592
565
- !insertmacro CheckAllUninstalled
593
+ !insertmacro CheckAllUninstalled ${__LINE__}
566
594
${EndIf}
567
595
568
596
!insertmacro SetInstallPath
@@ -594,13 +622,14 @@ CLTDone_${CLTID}:
594
622
!undef CLTID
595
623
!macroend
596
624
597
- !macro CheckMIESPresent Path NiceInfo
625
+ !macro CheckMIESPresent Path NiceInfo uid
598
626
!insertmacro CheckLinkTarget " ${Path}\Igor Procedures" " MIES_Include.ipf"
599
627
Pop $1
600
- IntCmp $1 0 + 4
628
+ IntCmp $1 0 MacroEnd_ ${uid}
601
629
IfSilent +2
602
630
MessageBox MB_OK |MB_ICONSTOP " It appears that there is already MIES for ${NiceInfo} installed. Please remove MIES manually first."
603
- Quit
631
+ !insertmacro QuitWithCode ERROR_MIES_ALREADY_INSTALLED
632
+ MacroEnd_${uid} :
604
633
!macroend
605
634
606
635
!macro CreateIgorDirs
@@ -672,31 +701,30 @@ MIESCheck9:
672
701
StrLen $0 $INSTALL_I9PATH
673
702
${If} $0 = 0
674
703
IfSilent +2
675
- MessageBox MB_OK " Bug: I have no Igor 9 Path."
676
- Quit
704
+ MessageBox MB_OK " Bug: I have no Igor 9 Path."
705
+ !insertmacro QuitWithCode ERROR_NO_IGOR9_PATH
677
706
${EndIf}
678
- !insertmacro CheckMIESPresent " $DOCUMENTS\WaveMetrics\Igor Pro 9 User Files" " Igor Pro 9"
679
- !insertmacro CheckMIESPresent " $INSTALL_I9PATH" " Igor Pro 9"
707
+ !insertmacro CheckMIESPresent " $DOCUMENTS\WaveMetrics\Igor Pro 9 User Files" " Igor Pro 9" ${__LINE__}
708
+ !insertmacro CheckMIESPresent " $INSTALL_I9PATH" " Igor Pro 9" ${__LINE__}
680
709
MIESCheck9End:
681
710
IntCmp $INSTALL_I1064 1 MIESCheck10
682
711
Goto MIESCheck10End
683
712
MIESCheck10:
684
713
StrLen $0 $INSTALL_I10PATH
685
714
${If} $0 = 0
686
715
IfSilent +2
687
- MessageBox MB_OK " Bug: I have no Igor 10 Path."
688
- Quit
716
+ MessageBox MB_OK " Bug: I have no Igor 10 Path."
717
+ !insertmacro QuitWithCode ERROR_NO_IGOR10_PATH
689
718
${EndIf}
690
- !insertmacro CheckMIESPresent " $DOCUMENTS\WaveMetrics\Igor Pro 10 User Files" " Igor Pro 10"
691
- !insertmacro CheckMIESPresent " $INSTALL_I10PATH" " Igor Pro 10"
719
+ !insertmacro CheckMIESPresent " $DOCUMENTS\WaveMetrics\Igor Pro 10 User Files" " Igor Pro 10" ${__LINE__}
720
+ !insertmacro CheckMIESPresent " $INSTALL_I10PATH" " Igor Pro 10" ${__LINE__}
692
721
MIESCheck10End:
693
722
694
723
IntCmp $ALLUSER 0 AdminCheckDone
695
724
IntCmp $ISADMIN 1 AdminCheckDone
696
725
IfSilent +2
697
726
MessageBox mb_iconstop " You selected installation for All Users, but you don't have Administrator rights."
698
- SetErrorLevel 740 ; ERROR_ELEVATION_REQUIRED
699
- Quit
727
+ !insertmacro QuitWithCode ERROR_ELEVATION_REQUIRED
700
728
AdminCheckDone:
701
729
702
730
!include " ${NSISINSTDIRLIST}"
@@ -768,7 +796,7 @@ InstallAEnd1064:
768
796
FileError:
769
797
IfSilent +2
770
798
MessageBox MB_OK " Can not create $INSTDIR\uninstall.lst."
771
- Quit
799
+ !insertmacro QuitWithCode ERROR_CANNOT_CREATE_UNINSTALL_FILELIST
772
800
773
801
EndOfLinks:
774
802
FileClose $FILEHANDLE
@@ -828,8 +856,7 @@ SkipVCRedistInstallation:
828
856
IntCmp $0 0 SkipASLRSetup
829
857
IfSilent +2
830
858
MessageBox MB_OK " Can not disable ASLR for Igor64.exe."
831
- SetErrorlevel 1
832
- Quit
859
+ !insertmacro QuitWithCode ERROR_CANNOT_DISABLE_ASLR
833
860
834
861
SkipASLRSetup:
835
862
@@ -839,8 +866,7 @@ SkipASLRSetup:
839
866
IntCmp $0 0 FixOffice365Done
840
867
IfSilent +2
841
868
MessageBox MB_OK " Can not apply Office365 fixes."
842
- SetErrorlevel 1
843
- Quit
869
+ !insertmacro QuitWithCode ERROR_CANNOT_FIX_OFFICE365
844
870
FixOffice365Done:
845
871
!insertmacro WriteITCRegistry
846
872
${If} ${RunningX64}
@@ -853,7 +879,9 @@ SkipITCSetup:
853
879
; Format of the json file:
854
880
; /Installation/User : <string> ; for what user target the installation was done, either "current" or "all"
855
881
; /Installation/WithHardware : <number> ; if the installation was done with hardware XOPs, either "1" or "0"
882
+ ClearErrors
856
883
FileOpen $FILEHANDLE " $INSTDIR\installation_configuration.json" w
884
+ IfErrors FileErrorInstallConfig
857
885
FileWrite $FILEHANDLE ' {$\n '
858
886
FileWrite $FILEHANDLE ' $\t "Installation" : {$\n '
859
887
IntCmp $ALLUSER 1 ConfigWriteUserAll
@@ -871,15 +899,22 @@ ConfigWriteWithHardwareEnd:
871
899
FileWrite $FILEHANDLE ' $\t }$\n '
872
900
FileWrite $FILEHANDLE ' }'
873
901
FileClose $FILEHANDLE
902
+ Goto EndOfInstallation
903
+ FileErrorInstallConfig:
904
+ IfSilent +2
905
+ MessageBox MB_OK " Can not create installation configuration file."
906
+ !insertmacro QuitWithCode ERROR_CANNOT_CREATE_INSTALLCONFIG
907
+
908
+ EndOfInstallation:
874
909
875
910
SectionEnd
876
911
877
912
# Uninstaller
878
913
879
914
function un.onInit
880
- !insertmacro PreventMultipleUninstaller
881
- !insertmacro StopOnIgor32
882
- !insertmacro StopOnIgor64
915
+ !insertmacro PreventMultipleUninstaller ${__LINE__}
916
+ !insertmacro StopOnIgor32 ${__LINE__}
917
+ !insertmacro StopOnIgor64 ${__LINE__}
883
918
functionEnd
884
919
885
920
Section " uninstall"
0 commit comments