![]() |
#1 |
Junior Member
Join Date: Feb 2017
Posts: 19
|
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: but that doesn't clear the error level and just always returns 0. Regards, Alex |
![]() |
![]() |
![]() |
#2 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,356
|
Try setting it to -1
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#3 |
Junior Member
Join Date: Feb 2017
Posts: 19
|
Thank you, Anders, this worked!
Maybe the value of -1 should be added to the docs for SetErrorLevel Regards, Alex |
![]() |
![]() |
![]() |
#4 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,356
|
It is a bug that -1 works like this. There is already a bug report about it on the tracker.
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#5 |
Junior Member
Join Date: Feb 2017
Posts: 19
|
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 |
![]() |
![]() |
![]() |
#6 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,356
|
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 |
![]() |
![]() |
![]() |
#7 |
Junior Member
Join Date: Feb 2017
Posts: 19
|
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 |
![]() |
![]() |
![]() |
#8 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,356
|
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 |
![]() |
![]() |
![]() |
|
Tags |
clear, seterrorlevel, uac |
Thread Tools | Search this Thread |
Display Modes | |
|
|