Adding Custom Exit Codes

//Adding Custom Exit Codes
Adding Custom Exit Codes 2016-01-29T18:44:42+00:00

The Toolkit Forums General Adding Custom Exit Codes

  • Author
    Posts
  • Adam
    Participant
    Post count: 5

    I saw that you can use Execute-Process -IgnoreExitCodes <String>, but can you add a custom one? I have an app that spits out 129 which states “you must reboot”, which is not the typical 3010 code.

    Also is there a way to make the bubble at the end say “you must reboot your machine”?

    Thanks.

  • Aman
    Keymaster
    Post count: 53

    Hi Adam,
    You can do both of those things with the toolkit.
    You can first capture the exit code of your installation into a variable by using the -passthru parameter with the execute-process function. Then use the Exit-Script function, passing that value out of the script.

    You can also use the show-balloontip function to create a custom balloon tip.
    These functions and their uses are outlined in the documentation which comes with the toolkit when you download it.

  • Adam
    Participant
    Post count: 5

    Thank you for the reply! I understand how to do the first part. Second part I got lost on though haha.

    The scenario is I am installing SAP 7.40 and it sometimes gives error 129 which just means to reboot, but since it doesn’t use 3010 like any normal app, it is considered a failed install.

    So the goal is to have 129 behave like 3010 and give a restart prompt, balloon, etc.

  • Muhammad Mashwani
    Keymaster
    Post count: 118

    Like Aman suggested above, do something like this:
    $ReturnCode = Execute-Process -IgnoreExitCodes ‘129’ -PassThru
    If ($ReturnCode.ExitCode -eq 129) {
    Exit-Script -ExitCode 3010
    }

  • Adam
    Participant
    Post count: 5

    This look correct?

    ## <Perform Installation tasks here>
    $ReturnCode = Execute-Process -Path ‘gui740_05_2-10013011.exe’ -Parameters ‘/noDLG’ -IgnoreExitCodes ‘129,145’ -PassThru
    If ($ReturnCode.ExitCode -eq 129) {Exit-Script -ExitCode 3010}
    If ($ReturnCode.ExitCode -eq 145) {Exit-Script -ExitCode 3010}

    • This reply was modified 2 years, 2 months ago by  Adam.
    • Adam
      Participant
      Post count: 5

      Not sure why it wont let me edit my post, but should I keep -IgnoreExitCodes in the above script? Is it required?

      Thanks again!

You must be logged in to reply to this topic.