Microsoft KB Archive/939085

= How to run scripts in an .osd file in Microsoft SoftGrid =

Article ID: 939085

Article Last Modified on 8/16/2007

-

APPLIES TO


 * Microsoft SoftGrid for Terminal Services
 * Microsoft SoftGrid for Windows Desktops

-



INTRODUCTION
This article describes how to run scripts in an .osd file in Microsoft SoftGrid. You must be a SoftGrid administrator to run a script.

You can run any number of scripts and any style of scripts in an .osd file. You can run scripts to overcome some limitations of programs. Or, you can use scripts to set up particular configurations that a program may require to run correctly.

You can pass a script that is written in almost any language from the .osd file of a SoftGrid-enabled program to a client that has the necessary interpreter installed. Organizations may have preexisting scripts that are written by using Microsoft Visual Basic, Perl, .bat files, .cmd files, or other similar files. If you follow the basic rules of scripting that are required in an .osd file, you can continue to use the existing scripts.

To include a script in an .osd file, you must determine the following:
 * When the script runs
 * Where the script runs
 * How the script runs



General rules
All scripts must be added between the  tags in an .osd file. You can refer to an existing script by its file name. Or, you can enter the exact syntax of the commands in the script section.

When the script runs
You can use the .osd file to run scripts at various times during the startup of SoftGrid-enabled programs. The &quot;SCRIPT TIMING and EVENT&quot; setting in the script comes first. Under this setting, the following attributes determine when the script runs:
 * PRE STREAM

This attribute runs the script before the program starts streaming. For example, use this attribute when you have to open a virtual private network (VPN) connection to the SoftGrid server before you run the program.
 * POST STREAM

This attribute runs the script after authorization and after the program starts streaming but before the Virtual Environment is set up.
 * PRE LAUNCH

This attribute runs the script inside the virtual environment before the program runs.
 * POST LAUNCH

This attribute runs the script after the program is started.
 * POST SHUTDOWN

This attribute runs the script after the program is shut down. For example, use this attribute to clean up configuration settings or to delete configuration files.

Where the script runs
The script can run in the following two locations:
 * In the Virtual Environment
 * Outside the Virtual Environment

Set the PROTECT attribute as follows:
 * PROTECT=True

This setting configures the script to run in the Virtual Environment. You can use this setting to run scripts that are used to troubleshoot issues.
 * PROTECT=False

This attribute configures the script to run outside the Virtual Environment. For example, you can use this setting to run scripts that copy files locally to the client.

How the script runs
The new TIMEOUT attribute determines the following:
 * Whether the SoftGrid client waits for the script to finish
 * The period that the SoftGrid client will wait for the script to finish

For backward compatibility, the WAIT attribute is still supported in Microsoft SoftGrid 4.0.

Set these attributes as follows:
 * TIMEOUT
 * TIMEOUT=

The client will wait  seconds for the script to finish before the client returns an error.
 * TIMEOUT=0

The client will wait indefinitely for the script to finish.
 * WAIT
 * Wait=False

The client will continue without waiting for the script to finish.
 * Wait=True

The client will not start the next step until the script finishes.

Notes
 * The client does not support a pre-shutdown event. You cannot determine the exact moment at which a user will perform a shutdown. For example, you cannot predict when the user will click Close or when the user will press ALT+F4.
 * You can use scripts in any language. However, the language must be installed locally on the client computer.

Sample scripts
The following sample scripts show you how to use scripts in an .osd file.

Sample script 1
This sample script does the following:
 * It uses the SCRIPTBODY tag to contact a server by using its IP Address.
 * It deletes a drive mapping, and then it creates a new drive mapping by using the same drive letter.

   @echo on \n ping 192.168.100.100 \n net use x: /delete /y \n net use x: \\\\ServerName\\Achieve \n net use y: /delete /y \n net use y: \\\\ServerName\\Achieve\\claims\\Bethany \n   

Sample script 2
This sample script does the following:
 * It uses the SCRIPTBODY tag to map a network drive to a server's netlogon share.
 * It calls an existing .cmd file that is located on the mapped network drive.
 * It calls the Editini.exe file.
 * It adds a Temp path to the Word.ini file.

DEPENDENCY>   net use k: \\\\w2k-pdc\\netlogon \n CALL k:\\usr-w2k.cmd \n \\\\sft-softgrid\\shr\\editini.exe c:\\word\\word.ini &quot;FileLocations&quot; TempPath c:\\tem \n   

Sample script 3
This sample script does the following:
 * It uses the %SFT_MNT% variable to refer to the client’s virtual mount point. This variable is typically Q:\.
 * It calls the Proflwiz.exe program. The absolute path is used because the SoftGrid mount point is typically not part of the client’s path statement.

  %SFT_MNT%\\OfficeXP\\Office10\\proflwiz.exe</SCRIPTBODY> </SCRIPT>

<div class="references_section">