Old 19th February 2015, 15:41   #1
Mike C
Junior Member
 
Join Date: Feb 2015
Posts: 6
Return value from !system

Hi all,

LTL, FTP here. I'm trying to figure out how to get hold of the return value from a system command executed at compile-time, using the !system command.

I've checked out the documentation at http://nsis.sourceforge.net/Docs/Chapter5.html#system but I'm being a bit dense about figuring out the 'symbol' bit, and there isn't a code example.

The format is, as the doc says:

code:
!system command symbol


What exactly is 'symbol' and how do I define it, and get the value from it?

Any help appreciated! Thanks.
Mike C is offline   Reply With Quote
Old 19th February 2015, 16:33   #2
aerDNA
Senior Member
 
aerDNA's Avatar
 
Join Date: Feb 2007
Location: Rijeka, Croatia
Posts: 225
With e.g. !system "some.exe" = 0 script will only compile if some.exe returns 0. But afaik you can't get the exit code and use it for flow control if that's what you want.

PostEnd:
aerDNA is offline   Reply With Quote
Old 19th February 2015, 16:40   #3
Mike C
Junior Member
 
Join Date: Feb 2015
Posts: 6
Quote:
Originally Posted by aerDNA View Post
With e.g. !system "some.exe" = 0 script will only compile if some.exe returns 0. But afaik you can't get the exit code and use it for flow control if that's what you want.
OK, thanks for that! Just tried it out, and it works fine for me. I can go with simply failing the script compilation for now.

Many thanks for your help!
Mike C is offline   Reply With Quote
Old 19th February 2015, 16:47   #4
aerDNA
Senior Member
 
aerDNA's Avatar
 
Join Date: Feb 2007
Location: Rijeka, Croatia
Posts: 225
Quote:
Originally Posted by aerDNA View Post
afaik you can't get the exit code
For the record, there is way: you could run a batch file that runs the exe, checks errorlevel and outputs the result in a text file; then you get it with !searchparse.

PostEnd:
aerDNA is offline   Reply With Quote
Old 19th February 2015, 16:49   #5
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
code:
!system command symbol
!if ${symbol} = 0
...
!else
...
!endif

It essentially does a !define symbol [return_value], thus ${symbol} can then be used in your script at compile time.

Only works with NSIS 3.0+.

Stu
Afrow UK is offline   Reply With Quote
Old 19th February 2015, 17:09   #6
Mike C
Junior Member
 
Join Date: Feb 2015
Posts: 6
Quote:
Originally Posted by Afrow UK View Post
Only works with NSIS 3.0+.
Aha! That's what I was missing - we're using 2.46 here.

Your code example is exactly how I interpreted the documentation. It's good to know that I wasn't being dense after all (on this occasion...).
Mike C is offline   Reply With Quote
Old 19th February 2015, 17:14   #7
aerDNA
Senior Member
 
aerDNA's Avatar
 
Join Date: Feb 2007
Location: Rijeka, Croatia
Posts: 225
I didn't know there were changes to !system. Nice.

PostEnd:
aerDNA is offline   Reply With Quote
Old 19th February 2015, 19:45   #8
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,548
Quote:
Originally Posted by aerDNA View Post
I didn't know there were changes to !system. Nice.
This and !makensis was added mostly to help people sign the uninstaller, it allows you to do some %temp% cleanup before aborting with a error message...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
!system, compile-time, nsis

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