Old 13th June 2010, 18:51   #1
Squirre1
Member
 
Join Date: Aug 2001
Posts: 50
Send a message via ICQ to Squirre1
ErrorLevel Not returning

I am using a custom errorlevel in an installer and it does not appear to be returning as necessary...

PHP Code:
      !insertmacro logme $INSTLOG "OS Detected: Windows $R0 $R1l
      
!insertmacro logme $INSTLOG "Install Error: OS Not Supported" l
      MessageBox MB_OK
|MB_ICONINFORMATION "Please provide the following information to support.$\r$\n$\r$\nInstallation of ${APP_DESC} failed with error: OS Not Supported$\r$\n$\r$\nTerminating Installation"  /SD IDOK
      SetErrorLevel 999
      SetRebootFlag false
      
goto _ierrored 
PHP Code:
    _ierrored:

    !
insertmacro logme $INSTLOG "Cleaning Up Temporary Files ... Please be Patient" b
    SetOutPath $INSTDIR
    
!insertmacro RemoveFilesAndSubDirs "$INSTDIR\${APP_NAME}"
    
RMDir /"$INSTDIR\${APP_NAME}"

    
!insertmacro logme $INSTLOG "*** ${APP_DESC} Installation Ended in Error ***" b
    StrCpy $FINISHPAGE_TEXT 
"The installation of ${APP_DESC} has resulted in an error and was not completed.$\r$\n$\r$\nClick Finish to close this wizard."

    
_end
There are just the two sections of any relavence so you can see whats taking place.. The log is generating correctly, but there errorlevel does not appear to be getting set.

13.06.2010 12:28:47 *-----------------------------------------------------*
13.06.2010 12:28:47 ### Microsoft Windows Installer 4.5 Installation Starting
13.06.2010 12:28:47 ### Build Verison: 1.0.0.1
13.06.2010 12:28:47 ### Runtime: 6/13/2010 12:28:47
13.06.2010 12:28:47 ### Switches: /S
13.06.2010 12:28:47 *-----------------------------------------------------*
13.06.2010 12:28:47
13.06.2010 12:28:47 Silent Installation has been Requested
13.06.2010 12:28:47 Running Pre-installation Processes
13.06.2010 12:28:47 Detecting the Running Operating System
13.06.2010 12:28:47 OS Detected: Windows 7 64
13.06.2010 12:28:47 Install Error: OS Not Supported
13.06.2010 12:28:47 Cleaning Up Temporary Files ... Please be Patient
13.06.2010 12:28:47 *** Microsoft Windows Installer 4.5 Installation Ended in Error ***

Any Ideas are greatly appreciated..

Thanks...
Squirre1 is offline   Reply With Quote
Old 13th June 2010, 18:57   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 3,464
I don't see Quit in there

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 13th June 2010, 19:12   #3
Squirre1
Member
 
Join Date: Aug 2001
Posts: 50
Send a message via ICQ to Squirre1
Do you have to have a Quit in order for it to return the errorlevel... I thought the SetErrorLevel was enough for it to assign the errorlevel for when the installation finishes..? Please correct me if I am wrong.

In a commandline window I do the following...

>Set errorlevel=15 ; Set a dummy errorlevel level to validate it changes
>Installer.exe /S
>echo %errorlevel% ; Still returns 15 for the errorlevel, like the installer NEVER influenses it..

Last edited by Squirre1; 13th June 2010 at 19:15. Reason: Added more info...
Squirre1 is offline   Reply With Quote
Old 13th June 2010, 20:15   #4
Squirre1
Member
 
Join Date: Aug 2001
Posts: 50
Send a message via ICQ to Squirre1
Just as a FYI, I tested with the Quit in there, and it is STILL not returning the errorlevel correctly. Not sure what is up...

I have also tested different methods of SetErrorLevel for ex.
SetErrorLevel "999"
SetErrorLevel 999
SetErrorLevel '999'

All with the same result, none of them return...
Attached Files
File Type: nsi Installer.nsi (16.4 KB, 79 views)

Last edited by Squirre1; 13th June 2010 at 20:18. Reason: Just because
Squirre1 is offline   Reply With Quote
Old 13th June 2010, 20:43   #5
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
I believe SetErrorLevel must come immediately before your Quit command (not too sure if GoTo's are allowed), as otherwise NSIS' own code for error level setting upon installer exit may override whatever you set.
Worth a try, at least - our installers have it set immediately before Quit / last command of .onGuiEnd , and work correctly.
Animaether is offline   Reply With Quote
Old 13th June 2010, 21:22   #6
demiller9
Senior Member
 
Join Date: Mar 2006
Location: Dallas
Posts: 454
It looks like you have masked the true errorlevel by setting a variable with that name before the program started. Remove the "Set ErrorLevel=15" and see if your program returns 999.
demiller9 is offline   Reply With Quote
Old 13th June 2010, 21:32   #7
Squirre1
Member
 
Join Date: Aug 2001
Posts: 50
Send a message via ICQ to Squirre1
That does not mask it, anytime the NSIS installer finishes it should overwrite the previous errorlevel... I have even created small scripts based on some recommendations from the others...

Doesn't Work: Post Execution Errorlevel = 0
PHP Code:
Name "SetErrorLevel test"

OutFile "SetErrorLevel.exe"

Function .onInit
FunctionEnd

Section
  SetErrorLevel 25
SectionEnd 
Doesn't Work: Post Execution Errorlevel = 0
PHP Code:
Name "SetErrorLevel test"

OutFile "SetErrorLevel.exe"

Function .onInit
FunctionEnd

Section
SectionEnd

Function .onGUIEnd
  SetErrorlevel 25
  Quit
FunctionEnd 
No matter how you do it, for some reason the errorlevel is not returning... I have another installer where errorlevel is assigned with no problem the exact same way as in the first post, BUT it is not assigned manually, but by the installer... For ex.

ExecWait "blah blah blah" $0
SetErrorLevel $0

That works find with no problem... So not quite sure what is up... Im Stumped for the moment...
Squirre1 is offline   Reply With Quote
Old 13th June 2010, 21:43   #8
Squirre1
Member
 
Join Date: Aug 2001
Posts: 50
Send a message via ICQ to Squirre1
So, a little more into it.. And this is even a little more messed up...

From the scripts in my previous post. If you call it from command line as just seterrorlevel.exe it returns with 0. But if you call it from command line as cmd /c "seterrorlevel.exe" it actually does return the errorlevel of 25... Ugh... Now I am lost, if it is just an interfacing issue or if there is some underlying thing in my NSIS script that is not getting set...
Squirre1 is offline   Reply With Quote
Old 13th June 2010, 22:40   #9
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 3,464
To verify error levels, use another nsis script and call ExecWait yourapp.exe $0 and check the register, cmd.exe has many problems with error codes

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 13th June 2010, 23:15   #10
Wizou
Senior Member
 
Join Date: Aug 2007
Location: Paris, France
Posts: 302
Anders is right..
In cmd.exe, if you want to catch the correct ERRORLEVEL from a non-console app, you must call
code:
start "" /WAIT myapp.exe
echo %ERRORLEVEL%


or make a program (like Anders is suggesting) that catch the errorlevel for you
Wizou is offline   Reply With Quote
Old 14th June 2010, 01:48   #11
demiller9
Senior Member
 
Join Date: Mar 2006
Location: Dallas
Posts: 454
errorlevel is not the same as %errorlevel%

Raymond Chen wrote an article that explains ERRORLEVEL is not the same as %ERRORLEVEL%. That's why I suggested that your "Set errorlevel=0" and "echo %errorlevel% are not displaying the actual errorlevel that the exe returns.

You can also refer to the MS documentation of the "IF" command which says
Quote:
%errorlevel% expands into a string representation of the current value of errorlevel, provided that there is not already an environment variable with the name ERRORLEVEL
demiller9 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