Microsoft KB Archive/930973

From BetaArchive Wiki
Knowledge Base


How to abort a program start after a script failure

Article ID: 930973

Article Last Modified on 7/11/2007



APPLIES TO

  • Microsoft SoftGrid for Terminal Services
  • Microsoft SoftGrid for Windows Desktops



SUMMARY

This article describes how to abort a program start after a script failure.

MORE INFORMATION

Microsoft SoftGrid Client 3.2 and SoftGrid Client 4 support the following new attributes for the SCRIPT element in .osd files:

  • ABORTRESULT
  • SUCCESSRESULT

If the ABORTRESULT attribute is specified, the client checks the exit code of the script when the script finishes. If the exit code matches the ABORTRESULT value, the client silently aborts the program start. The ABORTRESULT attribute can be used for the following scripts:

  • Pre-stream
  • Post-stream
  • Pre-launch
  • Post-launch

For post-launch scripts, the program is silently terminated because it has already completely started. No message is displayed to the user in any of these cases.

If the SUCCESSRESULT attribute is specified, and if the ABORTRESULT value does not match the exit code of the script, the client will check the script exit code to determine whether the code matches the SUCCESSRESULT value. If the two values match, the start process continues. If the values do not match, the start fails for pre-stream scripts, for post-stream scripts, and for pre-launch scripts. Additionally, the user will see an error message. For post-launch scripts, if the script returns something other than the SUCCESSRESULT value, the program will be immediately terminated. Additionally, the user will see the standard shut-down message in the notification area.

Requirements

  • The ABORTRESULT attribute and the SUCCESSRESULT attribute are optional.
  • The attribute values must be 32-bit numbers.
  • If a TIMEOUT value is not specified, the WAIT value must be TRUE.
  • If a TMIEOUT value is specified, the WAIT value can be either TRUE or FALSE.
  • The value of SHUTDOWN for the EVENT attribute is not supported.

Configuring the .osd file

  1. Open the .osd file by using a text editor.
  2. Type the values for the SUCCESSRESULT attribute and for the ABORTRESULT attribute in the SCRIPT element.
  3. Type the desired exit codes between the quotation marks for each attribute. Refer to the following example text.

    <DEPENDENCY>
      <SCRIPT TIMING="PRE" EVENT="LAUNCH" PROTECT="TRUE" WAIT="TRUE"
        TIMEOUT="10" SUCCESSRESULT="1" ABORTRESULT="0">
        <SCRIPTBODY>IF %OS% == Windows_NT (exit 1) ELSE exit 0</SCRIPTBODY>
      </SCRIPT>
    </DEPENDENCY>
  4. Save and then exit the .osd file.

Behavior conditions

The program will start if the following conditions are true:

  • The exit code equals the SUCCESSRESULT value, or the SUCCESSRESULT value is null.
  • The exit code does not equal ABORTRESULT value.
Exit Code SUCCESSRESULT ABORTRESULT Client Action
1 1 0 Program starts
1 1 Null Program starts
1 Null 0 Program starts

The program will silently exit if the following conditions are true:

  • An ABORTRESULT value is specified.
  • The exit code equals the ABORTRESULT value regardless of whether a SUCCESSRESULT value is specified.
Exit Code SUCCESSRESULT ABORTRESULT Client Action
0 1 0 Program silently exits
0 0 0 Program silently exits
0 Null 0 Program silently exits

The program will not start if the following conditions are true:

  • A SUCCESSRESULT value is specified.
  • The exit code does not equal the SUCCESSRESULT value or the ABORTRESULT value regardless of whether an ABORTRESULT value is specified.

Additionally, you receive an error message that contains the following error code:

xxxxxx-xxxxxx18-0000000n


Notes

  • In this code, n represents the actual exit code.
  • This error code is also written to the SoftGrid Client log file (Sftlog.txt).
Exit Code SUCCESSRESULT ABORTRESULT Client Action
0 1 1 18-00000000
2 1 Null 18-00000002

For more information about this error code, click the following article number to view the article in the Microsoft Knowledge Base:

930694 Error message when you try to start a SoftGrid program: "The SoftGrid Client could not launch <program>. Error code: <xxxxxx-xxxxxx>18-0000000<n>


Keywords: kbhowto kbexpertiseinter KB930973