SoftGrid: Scripting within an OSD file
I noticed some posts on the SoftGrid Forums lately that could be addressed with some useful scripting with the .OSD files for a SoftGrid package. Scripting within .OSD files is a very powerful feature and can be used to solve or create workarounds for a vast number of situations. This is an excerpt of some text that was created to give the basics of the scripting concept. I try to go into detail on the Whats and the Hows and I also put in several script examples at the end. These examples are actual scripts that have been used in the field. Along with the example is an explanation of what the script is doing. After reading this article however, try to look at just the script example and decipher for yourself what it is doing. A mini self quiz if you will.
Scripts written in almost any language can be passed from the OSD file of a Microsoft SoftGrid Application Virtualization enabled application to a client that has the necessary interpreter in place. Organizations may have preexisting scripts written in Visual Basic, Perl, .bat files, .cmd files, etc. that are required for their applications to run effectively. By following the basic rules of scripting in an OSD file those existing scripts can be leveraged here as well.
The following questions on “When�, “Where� and “How� a script runs need to be answered before the script can be placed inside the OSD file.
All scripts must be placed between the <DEPENDENCY> tags within the OSD files. The Sequence Engineer can choose to either refer to an existing by its file name or can enter the exact syntax of the commands in the script section.
“WHEN� The OSD file can launch scripts at various points within the launching of Microsoft SoftGrid Application Virtualization-enabled applications. The script’s first setting determines when the script will run:
SCRIPT TIMING and EVENT:
PRE STREAM: Before the application begins streaming. (For instance, if the user needs to open a VPN to Microsoft SoftGrid Application Virtualization Server prior to running the application.)
POST STREAM: Run after authorization and streaming but before the Virtual Environment is setup.
PRE LAUNCH: Run inside of virtual environment, before execution begins.
POST LAUNCH: After the application is launched.
POST SHUTDOWN: Clean up activity or deleting settings files.
The following flow chart depicts the sequence of events when scripts are used within an OSD file.
“WHERE�
The next item that must be determined in running scripts is “Where� the script will run. There are only two options available here, either inside the virtual environment or outside it
Protect:
Protect=True: Allows the script to run within the protected environment. This script placement can be very useful for troubleshooting.
Protect=False: Allows the script to run outside the virtual environment. This script placement can be very effective when files need to copied locally to a client but there is no need to penetrate the virtual environment.
“HOW�
The next item that must be determined in running scripts is “How� the script will run. This option defines how much time, if any, the script will wait to completely execute. The new “TIMEOUT� attribute is used to determine the amount of time in seconds that the Microsoft SoftGrid Application Virtualization client will wait for the OSD file’s script to complete. For backwards compatibility the WAIT attribute is still supported in Microsoft SoftGrid Application Virtualization 4.1. A script that runs in a synchronous manner will run each step of the script without waiting for the next to have been completed.
TIMEOUT:
TIMEOUT=xx: The client will wait xx seconds for the script to complete before returning an error.
TIMEOUT=0: The client will wait indefinitely for the script to complete.
Wait:
Wait=False: Continue without waiting for the script to finish.
Wait=True: Do not start the next step until the script finishes.
Note: The client does not support a PRE SHUTDOWN event (it is not possible to know the exact instant before a user clicks, for example, the [X] in the upper right corner, or types Alt+F4). The Protect attribute specifies whether the script runs inside or outside the virtual environment. The Wait attribute specifies whether the client waits for the script to finish before proceeding to the next phase. Scripts may be written in any language, but the language must be installed locally on the client machine.
There are two types of scripts that can be used in the OSD file, <SCRIPTBODY> and <HREF>. The following table describes each type. You can decide for yourself which one is the better to use in your situation or environment. I treat this table as a score card for the script types.
Microsoft, SoftGrid, Script, Scripting, OSD, Guide, Tips and Tricks, Knowledgebase


Leave a comment »