WINAMP.COM | Forums : Powered by vBulletin version 2.3.9 WINAMP.COM | Forums > Developer Center > NSIS Discussion > Set silent installer exit code?
  Last Thread   Next Thread
Author
Thread Post New Thread    Post A Reply
BSOD2600
Member

Registered: Jan 2006
From: USA

Question Set silent installer exit code?

How does one set a unique exit code/error level and/or error message when using the silent installer feature? I've already searched and found the following:
* How to set exit errorlevel code
* Error Level when installer ends

Neither threads had clear solutions to this problem. I've tried a bunch of various code trying to abort/quit in .onInit and other custom page functions. None appear to set the dos errorlevel (or if it does, its 9009 which clearly isn't my custom errorlevel).

Basically, I'm passing in a silent install configuration file, parsing it out for the stuff I need, running checks on the data the user provided and then if need be, quit the installer with unique error codes/messages depending what is wrong. I realize while one can display a Messagebox for the error, that sort of defeats the purpose of a "silent installer".

Suggestions?

Quick Link | Report this post to a moderator | IP: Logged

BSOD2600 is offline Old Post 10-19-2009 06:23 AM
Click Here to See the Profile for BSOD2600 Click here to Send BSOD2600 a Private Message Find more posts by BSOD2600 Add BSOD2600 to your buddy list Edit/Delete Message Reply w/Quote
MSG
Senior Member

Registered: Oct 2006
From:

In the thread you linked, kickik said you can't set your own exit code in NSIS.

Quick Link | Report this post to a moderator | IP: Logged

MSG is offline Old Post 10-19-2009 08:01 AM
Click Here to See the Profile for MSG Click here to Send MSG a Private Message Find more posts by MSG Add MSG to your buddy list Edit/Delete Message Reply w/Quote
ChocJunkie
Senior Member

Registered: Oct 2009
From: Germany

quote:
Originally posted by MSG
In the thread you linked, kickik said you can't set your own exit code in NSIS.
For what reason does SetErrorLevel exist, if it's not possible to set a own exit code? Especially because the manual says so: http://nsis.sourceforge.net/Docs/AppendixD.html#D.1

CJ

Quick Link | Report this post to a moderator | IP: Logged

ChocJunkie is offline Old Post 10-19-2009 08:23 AM
Click Here to See the Profile for ChocJunkie Click here to Send ChocJunkie a Private Message Find more posts by ChocJunkie Add ChocJunkie to your buddy list Edit/Delete Message Reply w/Quote
BSOD2600
Member

Registered: Jan 2006
From: USA

quote:
Originally posted by ChocJunkie
For what reason does SetErrorLevel exist, if it's not possible to set a own exit code? Especially because the manual says so: http://nsis.sourceforge.net/Docs/AppendixD.html#D.1

CJ


I agree and saw it in the manual too, but am unable to actually have it work.

Would you please provide sample code demonstrating it working?

Quick Link | Report this post to a moderator | IP: Logged

BSOD2600 is offline Old Post 10-19-2009 10:12 AM
Click Here to See the Profile for BSOD2600 Click here to Send BSOD2600 a Private Message Find more posts by BSOD2600 Add BSOD2600 to your buddy list Edit/Delete Message Reply w/Quote
MSG
Senior Member

Registered: Oct 2006
From:

quote:
Originally posted by ChocJunkie
For what reason does SetErrorLevel exist, if it's not possible to set a own exit code? Especially because the manual says so: http://nsis.sourceforge.net/Docs/AppendixD.html#D.1

CJ


Hmmm. Fair enough. To use that, I'd try putting IfSilent into .onGuiEnd or something like that.

Quick Link | Report this post to a moderator | IP: Logged

MSG is offline Old Post 10-19-2009 11:46 AM
Click Here to See the Profile for MSG Click here to Send MSG a Private Message Find more posts by MSG Add MSG to your buddy list Edit/Delete Message Reply w/Quote
BSOD2600
Member

Registered: Jan 2006
From: USA

quote:
Originally posted by MSG
Hmmm. Fair enough. To use that, I'd try putting IfSilent into .onGuiEnd or something like that.


http://nsis.sourceforge.net/Docs/Chapter4.html#4.12
quote:
When an installer or an uninstaller is silent, not all callback functions are called. .onGUIInit, .onGUIEnd, their uninstaller equivalents and any callback related to a specific page or page type will not be called.

Quick Link | Report this post to a moderator | IP: Logged

BSOD2600 is offline Old Post 10-19-2009 05:31 PM
Click Here to See the Profile for BSOD2600 Click here to Send BSOD2600 a Private Message Find more posts by BSOD2600 Add BSOD2600 to your buddy list Edit/Delete Message Reply w/Quote
MSG
Senior Member

Registered: Oct 2006
From:

.oninstsuccess and .oninstfailed then? Or just at the end of the last section.

Quick Link | Report this post to a moderator | IP: Logged

MSG is offline Old Post 10-20-2009 11:27 AM
Click Here to See the Profile for MSG Click here to Send MSG a Private Message Find more posts by MSG Add MSG to your buddy list Edit/Delete Message Reply w/Quote
BSOD2600
Member

Registered: Jan 2006
From: USA

quote:
Originally posted by BSOD2600
I agree and saw it in the manual too, but am unable to actually have it work.

Would you please provide sample code demonstrating it working?

Quick Link | Report this post to a moderator | IP: Logged

BSOD2600 is offline Old Post 10-20-2009 01:04 PM
Click Here to See the Profile for BSOD2600 Click here to Send BSOD2600 a Private Message Find more posts by BSOD2600 Add BSOD2600 to your buddy list Edit/Delete Message Reply w/Quote
pengyou
Senior Member

Registered: Mar 2003
From:

I tried modifying the MUI2 'Basic.nsi' example to return an error code. When I ran it using /S on the command-line it returned the correct error code.

I don't understand your problem; perhaps because you have not supplied enough information? For example: How are you making your installer silent?

Quick Link | Report this post to a moderator | IP: Logged

pengyou is offline Old Post 10-20-2009 04:02 PM
Click Here to See the Profile for pengyou Click here to Send pengyou a Private Message Find more posts by pengyou Add pengyou to your buddy list Edit/Delete Message Reply w/Quote
BSOD2600
Member

Registered: Jan 2006
From: USA

I'm making the installer silent via the /S command.

Alright, so taking your basic.nsi example, I modified it to set an error level and it doesn't appear to work. Would you please post your sample code?

code:
C:\Program Files\NSIS\Examples\Modern UI>%errorlevel% '9009' is not recognized as an internal or external command, operable program or batch file. C:\Program Files\NSIS\Examples\Modern UI>Basic.exe /S C:\Program Files\NSIS\Examples\Modern UI>%errorlevel% '9009' is not recognized as an internal or external command, operable program or batch file. ---------------------- basic.nsi ;-------------------------------- ;Include Modern UI !include "MUI2.nsh" ;-------------------------------- ;General ;Name and file Name "Modern UI Test" OutFile "Basic.exe" ;Default installation folder InstallDir "$LOCALAPPDATA\Modern UI Test" ;Get installation folder from registry if available InstallDirRegKey HKCU "Software\Modern UI Test" "" ;Request application privileges for Windows Vista RequestExecutionLevel user ;-------------------------------- ;Interface Settings !define MUI_ABORTWARNING ;-------------------------------- ;Pages !insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt" !insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES ;-------------------------------- ;Languages !insertmacro MUI_LANGUAGE "English" ;-------------------------------- ;Installer Sections Section "Dummy Section" SecDummy IfSilent 0 +4 SetErrorLevel 1234 Abort SetOutPath "$INSTDIR" ;ADD YOUR OWN FILES HERE... ;Store installation folder WriteRegStr HKCU "Software\Modern UI Test" "" $INSTDIR ;Create uninstaller WriteUninstaller "$INSTDIR\Uninstall.exe" SectionEnd ;-------------------------------- ;Descriptions ;Language strings LangString DESC_SecDummy ${LANG_ENGLISH} "A test section." ;Assign language strings to sections !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_DESCRIPTION_TEXT ${SecDummy} $(DESC_SecDummy) !insertmacro MUI_FUNCTION_DESCRIPTION_END ;-------------------------------- ;Uninstaller Section Section "Uninstall" ;ADD YOUR OWN FILES HERE... Delete "$INSTDIR\Uninstall.exe" RMDir "$INSTDIR" DeleteRegKey /ifempty HKCU "Software\Modern UI Test" SectionEnd


What I really want to do, is to read in the silent answer file, parse it to check for issues and then throw various error codes/messages based before the installer actually gets to installing...

Quick Link | Report this post to a moderator | IP: Logged

BSOD2600 is offline Old Post 10-20-2009 05:44 PM
Click Here to See the Profile for BSOD2600 Click here to Send BSOD2600 a Private Message Find more posts by BSOD2600 Add BSOD2600 to your buddy list Edit/Delete Message Reply w/Quote
pengyou
Senior Member

Registered: Mar 2003
From:

I think I see what the problem is:

quote:
C:\Program Files\NSIS\Examples\Modern UI>Basic.exe /S

C:\Program Files\NSIS\Examples\Modern UI>%errorlevel%
'9009' is not recognized as an internal or external command,
operable program or batch file.
Try using a batch file to display the errorlevel. Here is what I used to test my script:
code:
test >type silent-demo.bat @echo off echo Run 'silent-mui-demo.exe' silently by supplying /S on command line silent-mui-demo.exe /S echo 'silent-mui-demo.exe /S' returned %ERRORLEVEL% echo. test >silent-demo Run 'silent-mui-demo.exe' silently by supplying /S on command line 'silent-mui-demo.exe /S' returned 1500 test >
"1500" is the expected value when the script is run silently. My script is attached.

Attachment: silent-mui-demo.nsi
This has been downloaded 30 time(s).

Quick Link | Report this post to a moderator | IP: Logged

pengyou is offline Old Post 10-20-2009 06:09 PM
Click Here to See the Profile for pengyou Click here to Send pengyou a Private Message Find more posts by pengyou Add pengyou to your buddy list Edit/Delete Message Reply w/Quote
BSOD2600
Member

Registered: Jan 2006
From: USA

Well heck, that made it easy and my existing code does work after all. Guess my validation was wrong the whole time.

Thanks!

Quick Link | Report this post to a moderator | IP: Logged

BSOD2600 is offline Old Post 10-20-2009 06:37 PM
Click Here to See the Profile for BSOD2600 Click here to Send BSOD2600 a Private Message Find more posts by BSOD2600 Add BSOD2600 to your buddy list Edit/Delete Message Reply w/Quote
All times are GMT. The time now is 07:57 PM. Post New Thread    Post A Reply
  Last Thread   Next Thread
WINAMP.COM | Forums : Powered by vBulletin version 2.3.9 WINAMP.COM | Forums > Developer Center > NSIS Discussion > Set silent installer exit code?
Show Printable Version
 | 
Email this Page
 | 
Subscribe to this Thread

Forum Jump:
 

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is off
vB code is ON
Smilies are ON
[IMG] code is ON