Old 10th February 2017, 10:46   #1
alexmitev
Junior Member
 
Join Date: Feb 2017
Posts: 15
Clear error level set by SetErrorLevel?

Hello,
(this is my first post here)
I'm using the UAC plugin to elevate an inner instance in the installer.
As documented, the UAC plugin calls SetErrorLevel to whatever the result from the inner process is. The problem is, after the elevated instance terminates, I cannot clear the error level, and at some cases I display again the outer instance and need to return the error that corresponds to it (e.g. user pressed Cancel button).
I expected the installer to set another error level (1 on Cancel button press, etc.), but that doesn't happen.
Seems to me like an NSIS issue: it should overwrite the current error level on Cancel press, script error, etc.
Right now, if the error level is once set, it's forever - NSIS never owerwrites it.
I've tried
code:
SetErrorLevel 0
SetErrorLevel ""


but that doesn't clear the error level and just always returns 0.

Regards,
Alex
alexmitev is offline   Reply With Quote
Old 10th February 2017, 14:25   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,507
Try setting it to -1

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 10th February 2017, 15:29   #3
alexmitev
Junior Member
 
Join Date: Feb 2017
Posts: 15
Thank you, Anders, this worked!
Maybe the value of -1 should be added to the docs for SetErrorLevel

Regards,
Alex
alexmitev is offline   Reply With Quote
Old 10th February 2017, 18:00   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,507
It is a bug that -1 works like this. There is already a bug report about it on the tracker.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 10th February 2017, 19:18   #5
alexmitev
Junior Member
 
Join Date: Feb 2017
Posts: 15
Does it mean that when the bug is fixed, it won't be possible to clear the error level?
I'm creating a plugin and would like my code to be compatible with future versions of NSIS. Maybe you should add a new function named ClearErrorLevel (like ClearErrors)?
Alex
alexmitev is offline   Reply With Quote
Old 10th February 2017, 20:12   #6
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,507
Yes, if the bug is fixed there will be a clearerrorlevel/reseterrorlevel instruction. The bug is actually that you cannot use -1 as the errorlevel because it currently gets special treatment.

This is a low priority issue and it is not clear how we are going to work around it but whatever we do, it is probably going to break plug-in compatibility in a minor way.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 10th February 2017, 20:47   #7
alexmitev
Junior Member
 
Join Date: Feb 2017
Posts: 15
Yes, this will only affect return codes by (un)installer for silent installs that rely on them.
Is it possible that you post to this thread when the changes get done, so that I know to update my code?
Regards,
Alex
alexmitev is offline   Reply With Quote
Old 10th February 2017, 21:27   #8
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,507
The change will be listed in the NSIS change log in the readme file but it is not going to happen any time soon. We first need to figure out what to actually do about it...

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

Tags
clear, seterrorlevel, uac

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