AppSense Scripting – with proper exit codes!

In order for the AppSense agent to correctly interact with scripts you are required to add exit codes so it knows what to do when a script has terminated.

What happens if you do not use exit codes

The EM agent is not aware of what the script is doing, as a result it will always return a success exit code.

For simple scripts where the results are immaterial this does not really post much of an issue. However more complex scripts with dependencies on the result may not behave as expected if no exit codes are passed to the agent.

One such example would be a drive mapping script

Note: There is a native AppSense mechanism within Environment Manager. Unfortunately if you wanted something beyond basic drive mapping such as retries on failed mapping attempts or more verbose logging this is not currently possible with the native toolset.

If the drive mapping has failed, subsequent actions relying on this action also are likely to fail so the AppSense agent needs to be aware of the outcome to take appropriate action rather than the default success result.

Script Exit Codes

VBScript

WScript.Quit <exit code>

i.e.

WScript.Quit 1 – failed

WScript.Quit 0 – success

Jscript

WScript.Quit(<exit code>)
i.e.
WScript.Quit(1) – failed

WScript.Quit(0) – success

PowerShell
exit (<exit code>)
i.e.
exit(1) – failed
exit(0) – success

Advertisements

One response to “AppSense Scripting – with proper exit codes!

  1. Pingback: AppSense EM: Node Groups and If..Then..Else | ConfigMonkey.co.uk·

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s