Old 23rd September 2011, 10:59   #1
heldain
Junior Member
 
Join Date: Sep 2011
Posts: 2
Exit code on embedded installers

Bad topic title I know.

I'm running an installer from my NSIS installer/script via the following:

code:
Section "app2" Section2

; Set Section properties
SetOverwrite on
SectionIn RO

;Set Section Files and Shortcuts
SetOutPath "$INSTDIR\Install\"
File "..\..\source\biginstaller\app2.exe"
ExecWait "$INSTDIR\Install\app2.exe"

SectionEnd



However I want to abort the whole script/installer if this installer fails to complete. I.e. if the exit code != 0.
I did find a 'Useful Script' that mentions this, but I'm being intellectually challenged and cant find how to apply it, as the example seems to omit this section.

http://nsis.sourceforge.net/Embedding_other_installers#Using_the_return_value_from_the_ExecWait
.

Suggestions please?
heldain is offline   Reply With Quote
Old 23rd September 2011, 12:18   #2
demiller9
Senior Member
 
Join Date: Mar 2006
Location: Dallas
Posts: 462
There is an optional parameter to capture the exit code. The manual is your friend.
demiller9 is offline   Reply With Quote
Old 23rd September 2011, 12:24   #3
heldain
Junior Member
 
Join Date: Sep 2011
Posts: 2
I saw that, however getting the exit code and handling it are different things. Its the handling that I'm struggling with.
heldain is offline   Reply With Quote
Old 23rd September 2011, 12:35   #4
LoRd_MuldeR
Major Dude
 
LoRd_MuldeR's Avatar
 
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
First of all you need to figure out what ExitCode the installer you run will return in for what situation.

This depends on the individual installer and may not be answered in general.

Then simply use a "StrCmp $1 <VAL> <GoIfEqual> <Otherwise>" to decide where to jump, depending on the ExitCode.

code:
ExecWait '"$INSTDIR\Install\app2.exe"' $1
StrCmp $1 0 Success ; Jump to 'Success' if (and only if) ExitCode was '0'

MessageBox MB_OK "Failed to install. Setup will exit!"
Quit

Success:
MessageBox MB_OK "Installed correctly"



For more complex things, you may want to have a look at ${switch} from LogicLib.nsh

My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc
My source of inspiration: http://youtu.be/lCwY4_0W1YI
LoRd_MuldeR is offline   Reply With Quote
Old 23rd September 2011, 12:38   #5
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
Or, preferably, use the logiclib and do:
${If} $1 == "<VAL>"
;stuff
${Else}
;other stuff
${EndIf}
MSG is offline   Reply With Quote
Old 23rd September 2011, 12:38   #6
demiller9
Senior Member
 
Join Date: Mar 2006
Location: Dallas
Posts: 462
Include LogicLib.nsh and then
code:
ExecWait "$INSTDIR\Install\app2.exe" $0
${If} $0 <> 0
; app2 has failed, must cleanup and stop
...
${EndIf}

or
code:
ExecWait "$INSTDIR\Install\app2.exe" $0
${If} $0 = 0
; app2 success, continue remaining operations
...
${EndIf}



(Edit: overlapping posts - MSG and I are suggesting the same thing.)

Last edited by demiller9; 23rd September 2011 at 12:40. Reason: overlapping posts - MSG and I are suggesting the same thing.
demiller9 is offline   Reply With Quote
Old 23rd September 2011, 12:39   #7
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
...wow, look at us being all helpful today. :P
MSG is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump