Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

How to run scripts in an .osd file in Microsoft App-V (SoftGrid)


View products that this article applies to.

INTRODUCTION

This article describes how to run scripts in an .osd file in Microsoft App-V (SoftGrid). You must be an App-V (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 an App-V (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

↑ Back to the top


More Information

General rules

All scripts must be added between the <DEPENDENCY> 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 App-V (SoftGrid)-enabled programs. The "SCRIPT TIMING and EVENT" 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 App-V (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:
  • Inside 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 App-V (SoftGrid) client waits for the script to finish
  • The period that the App-V (SoftGrid) client will wait for the script to finish
For backward compatibility, the WAIT attribute is still supported in Microsoft App-V 4.x and in Microsoft SoftGrid 4.x.

Set these attributes as follows:
  • TIMEOUT
    • TIMEOUT=x
      The client will wait x 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.
<DEPENDENCY>
<SCRIPT TIMING="PRE" EVENT="LAUNCH" WAIT="TRUE" PROTECT="TRUE">
<SCRIPTBODY> @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
</SCRIPTBODY>
</SCRIPT>
</DEPENDENCY>

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>
<SCRIPT EVENT="LAUNCH" TIMING="PRE" PROTECT="TRUE" WAIT="TRUE">
<SCRIPTBODY>
net use k: \\\\w2k-pdc\\netlogon \n
CALL k:\\usr-w2k.cmd \n
\\\\sft-softgrid\\shr\\editini.exe c:\\word\\word.ini "FileLocations" TempPath c:\\tem \n
</SCRIPTBODY>
</SCRIPT>
</DEPENDENCY>

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 App-V (SoftGrid) mount point is typically not part of the client’s path statement.
<DEPENDENCY>
<SCRIPT TIMING="PRE" EVENT="LAUNCH" WAIT="TRUE" PROTECT="TRUE">
<SCRIPTBODY>%SFT_MNT%\\OfficeXP\\Office10\\proflwiz.exe</SCRIPTBODY>
</SCRIPT>

↑ Back to the top


References

For more information about Microsoft App-V, visit the following Microsoft Web site:

↑ Back to the top


Keywords: kbscript, kbexpertiseadvanced, kbentirenet, kbhowto, kb

↑ Back to the top

Article Info
Article ID : 939085
Revision : 2
Created on : 8/1/2019
Published on : 8/1/2019
Exists online : False
Views : 360