ErrorLevel Not returning

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Squirre1
    Member
    • Aug 2001
    • 55

    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...
  • Anders
    Moderator
    • Jun 2002
    • 5643

    #2
    I don't see Quit in there
    IntOp $PostCount $PostCount + 1

    Comment

    • Squirre1
      Member
      • Aug 2001
      • 55

      #3
      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; 13 June 2010, 18:15. Reason: Added more info...

      Comment

      • Squirre1
        Member
        • Aug 2001
        • 55

        #4
        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
        Last edited by Squirre1; 13 June 2010, 19:18. Reason: Just because

        Comment

        • Animaether
          Major Dude
          • Jun 2001
          • 1173

          #5
          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.

          Comment

          • demiller9
            Senior Member
            • Mar 2006
            • 462

            #6
            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.

            Comment

            • Squirre1
              Member
              • Aug 2001
              • 55

              #7
              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...

              Comment

              • Squirre1
                Member
                • Aug 2001
                • 55

                #8
                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...

                Comment

                • Anders
                  Moderator
                  • Jun 2002
                  • 5643

                  #9
                  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

                  Comment

                  • Wizou
                    Senior Member
                    • Aug 2007
                    • 304

                    #10
                    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
                    My NSIS plug-ins: http://wiz0u.free.fr/prog/nsis.php

                    Comment

                    • demiller9
                      Senior Member
                      • Mar 2006
                      • 462

                      #11
                      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
                      %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

                      Comment

                      Working...
                      X