Using WiseScripts to Manage and Update Virtual Software Packages
After you install a virtual software layer on a collection of computers, how do you manage or update that layer? How do you delete, rename, or deactivate the layer, if your deployment system does not support this functionality? How do you replace a file, create a directory, or edit a registry key in the layer without recreating and redeploying the layer?
One excellent solution is to create and deploy WiseScripts to manage and update virtual software layers on a collection of computers. WiseScript is a high-level scripting language that consolidates dozens or hundreds of lines of code into predefined script actions. The Script Editor, which you use to create WiseScripts, includes script actions that are specifically designed for managing and updating virtual software layers. In this document, these script actions are referred to as SVS script actions (SVS stands for Software Virtualization Solution).
You can create WiseScripts to manage and update virtual software layers in either of the following products:
WiseScript Editor
WiseScript Editor with SVS script actions is available in Wise Package Studio 7.0, Wise Installation Studio 7.0, and Wise Installation Express 7.0.
WiseScript Package Editor
WiseScript Package Editor with SVS script actions is available in Wise Package Studio 7.0 and Wise Installation Studio 7.0.
The Script Editor functionality in both of these products is the same.
Topics include:
Overview of the Process
Using a WiseScript to manage or update a virtual software layer is generally a three-step process:
Step 1: Identify What You Want the WiseScript to Do
Before you can create the script, you must first identify exactly what you want the script to do. You might create a script that replaces a file in a layer with an updated file or edits a registry key. You might want the script to import a layer if it is not installed on a computer. If a layer is causing problems on only a few computers that have a unique configuration, you might create a script that updates the layer only on those computers.
Step 2: Create and Test the WiseScript
After you identify what you want the WiseScript to do, you use Script Editor to create the script. After you create the script, run it on a test machine to verify that it works correctly.
Step 3: Deploy and Run the WiseScript
After you create and test the script, you can use your deployment system to deploy and run it on a collection of computers.
Creating the WiseScript
You use Script Editor to create WiseScripts that you can use to manage and update virtual software layers. For details on using Script Editor, see the product's help and the article Performing System Administration Tasks With WiseScripts in the Altiris Knowledgebase (Article #27374).
Script Editor has a large set of script actions. A subset of these script actions are designed specifically for working with virtual software layers. Each of these script actions has SVS (Software Virtualization Solution) in its name. For your convenience, these script actions are grouped by default under the SVS Items title bar. When you create a WiseScript to manage or update a virtual software layer, you will usually use both SVS script actions and non-SVS script actions. The SVS specific script actions perform actions directly on a layer, while the other script actions function as they would in any WiseScript.
When you create a WiseScript to manage or update a virtual software layer, you generally must add script actions to find the layer's GUID before you add script actions to manage or update the layer. (For details, see Finding An SVS Layer on page 6.) This is because the actions that manage or update a layer require the layer's GUID, which you probably won't know. When you add script actions to find the layer, you can capture the layer's GUID in a variable. You can then use this variable to identify the layer's GUID when you add script actions to manage or update the layer. For details on the different script actions you can use to manage or update a layer, see SVS Script Actions (page 4).
Note
When you run a WiseScript to manage and update layers, the layers can be activated or deactivated. However, if the script contains the Export SVS Layer and Rename SVS Layer script actions, the layer must be deactivated for these actions to work.
SVS Script Actions
You add SVS script actions to a WiseScript to manage, update, find, and create SVS layers. For details on an SVS script action, open the script actions dialog and click F1.
Script Actions for Managing a Layer
Use these script actions to manage the state of a layer. When you export a layer you create a virtual software archive file (.VSA) that is portable. When you import a layer, you actually import a .VSA file to create a layer. For details on importing and exporting layers, see the Software Virtualization Solution documentation.
- Activate SVS Layer
- Deactivate SVS Layer
- Delete SVS Layer
- Export SVS Layer
- Import SVS Layer
- Set Activate SVS Layer on Start
Script Actions for Updating a Layer
Use these script actions to modify the files, registry keys, directories, or name of a layer. The Capture Application to SVS Layer script action also lets you update a layer by adding the files that are installed by an .EXE. (Example: If you have a layer for Microsoft* Word, you could create a WiseScript that installs Word templates. You could use the Capture Application to SVS Layer script action to capture the templates installed by the WiseScript .EXE and to add these templates to the Word layer.)
These script actions make changes to the read-only sublayer so they are not lost when the layer is reset. The exception is the Delete File from SVS Layer action. The changes it makes are made to the writeable sublayer. If you reset the layer after you use this action to delete a file, the deleted file is restored.
- Add File to SVS Layer
- Capture Application to SVS Layer
- Create Directory in SVS Layer
- Create Shortcut in SVS Layer
- Delete File from SVS Layer
- Edit Registry in SVS Layer
- Rename File or Directory in SVS Layer
- Rename SVS Layer
When you add some of these SVS script actions, the script actions dialog lets you enter the directory for a virtual layer. In this field, you can use SVS variables. You enclose the variables in square brackets [ ]. For a list and description of the SVS variables, see the Software Virtualization Solution documentation.
Script Actions for Finding a Layer
Use these script actions to find a layer's GUID. You then store the value of the GUID in a variable and use this variable in the SVS script actions that manage or update a layer. Use the find first and find next actions to iterate through all the layers on a computer.
- Find First SVS Layer
- Find Next SVS Layer
- Find SVS Layer GUID
Script Action for Creating a Layer
Use this script action to create an empty layer. You can then use the Capture Application to SVS script action to add an application to the layer, or use other SVS script actions to add directories, files, registry keys, and shortcuts to the layer.
- Create SVS Layer
Finding An SVS Layer
When you create a WiseScript to manage or update a software virtual layer, the WiseScript must find the layer before it can manage or update the layer.
Because each layer has a unique GUID, SVS script actions that manage or update layers use this GUID to find a layer. When you add these SVS script actions to a WiseScript, you must specify the layer's GUID. You can specify the layer's GUID with the actual GUID value (do not include the { } brackets) or a variable that represents this value. Because you probably won't know a layer's GUID, you will usually need to add actions to the WiseScript that find the layer's GUID and save its value in a variable. You can then use this variable in the SVS script actions that manage or update the layer.
How you find a layer's GUID depends on what you know about the layer. If you know a layer's name, you can use the Find SVS Layer GUID script action. When you add this action to a WiseScript, you simply enter the layer's name and a name for the variable that will store the GUID's value. For details, see Finding a Layer When You Know the Layer's Name.
If you don't know the name of layer, you can use the Find First SVS Layer and Find Next SVS Layer script actions to iterate through the layers on a computer and look for a file or registry key that is unique to the layer. When the script finds that file or registry key, it captures the value of the layer's GUID in a variable. For details, see Finding a Layer by Finding One of Its Files and Finding a Layer by Finding One of Its Registry Keys.
Finding a Layer When You Know the Layer's Name
If you know a layer's name, you can use the Find SVS Layer GUID script action to find it.
The following procedure creates a sample script that finds and activates Firefox. If it finds the Firefox layer, it displays a message that includes the layer's GUID. If it can activate the layer or if it is already active, it displays a layer activated message. The complete sample script with comments is listed below.
This script was created for Firefox version 1.5.0.6. You will need to modify the script for other versions.
To create the sample script
- Open your WiseScript product.
- If a previous WiseScript opens, select File menu > New.
If the New Installation File dialog appears, select Blank Script and click OK. - Double-click the Find SVS Layer GUID action, complete its dialog, and click OK.
- Layer Name
Enter Firefox 1.5.0.6 - GUID variable
Enter LAYERGUID - Return variable
Enter LAYERFOUND
- Layer Name
- Double-click the If Statement action, complete its dialog, and click OK:
- If Variable
Enter LAYERFOUND - operator drop-down list (unnamed)
Select Equal - The Value
Enter 0
- If Variable
- Double-click the Display Message action, complete its dialog, and click OK:
- Message Title
Enter Layer Found - Message Text
Enter The Firefox 1.5.0.6 layer was found. Its GUID is %LAYERGUID%. - Message Icon
Select Information
- Message Title
- Add an End Statement action to close the condition block.
- Double-click the Activate SVS Layer action, complete its dialog, and click OK:
- Layer GUID
Enter %LAYERGUID% - Return variable
Enter ACTIVATE
- Layer GUID
- Double-click the If Statement action, complete its dialog, and click OK:
- If Variable
Enter ACTIVATE - operator drop-down list (unnamed)
Select Equal - The Value
Enter 0
- If Variable
- Double-click the Display Message action, complete its dialog, and click OK:
- Message Title
Enter Layer Activated
- Message Text
Enter Firefox is activated - Message Icon
Select Information
- Message Title
- Add an End Statement action to close the condition block.
- Save and compile the script.
- If you have Firefox installed as a layer on your computer, click Run at the bottom of the Script Editor window to run the script.
If you don't have the Firefox layer installed, you can download it here.
Because this script activates Firefox, deactivate Firefox before you run the script. You will then be able to see if the script works correctly.
Your completed script should look like this without the comments:

Finding a Layer by Finding One of Its Files
If you don't know the name of a virtual software layer, you can create a WiseScript that finds the layer's GUID by finding one of its files. In the script, you specify the file you want to find in the layer. You then add script that iterates through all the layers on a computer. The script uses two Call DLL Function actions to find the file and the layer's GUID.
The following procedure creates a sample script that finds the GUID for the Firefox layer by finding a file in the Firefox installation. It has a script action that activates Firefox and another script action that deactivates any other layers. The complete sample script with comments is listed below.
This script was created for Firefox version 1.5.0.6. You may need to modify the script for other versions.
To create the sample script
- Open your WiseScript product.
- If a previous WiseScript opens, select File menu > New.
If the New Installation File dialog appears, select Blank Script and click OK. - Double-click the Set Variable action, complete its dialog, and click OK:
- Variable
Enter FILEPATH - New Value
Enter C:\Program Files\Mozilla Firefox\firefox.exe
- Variable
- Double-click the Set Variable action, complete its dialog, and click OK:
- Variable
Enter NONLAYERFILEPATH
- Variable
- To begin iterating through all layers whether they are active or not, double-click the
Find First SVS Layer action, complete its dialog, and click OK:- Layer GUID Variable
Enter LAYERGUID - Return Variable
Enter RETVAL
- Layer GUID Variable
- Double-click the While Statement action, complete its dialog, and click OK:
- While Variable
Enter RETVAL - operator drop-down list (unnamed)
Select Equals - The Value
Enter 0
- While Variable
- Double-click the Call DLL Function action to call an SVS .DLL to get the full non-layer path.
- Complete the top portion of the Call DLL Function dialog:
- DLL Pathname
Enter %SYS32%\fsllib32.dll - Function Name
Enter FSL2GetFullNonLayerPath - Call a function with variable parameter list
Select this option
- DLL Pathname
- On the Call DLL Function dialog, click Add for each parameter in the following table, complete the DLL Parameter Settings dialog, and click OK. Enter the parameters in the order they are listed.
Parameter Type Passing Type Value Source Variable Name string pointer Normal Variable LAYERGUID string pointer Normal Variable FILEPATH string pointer Normal Variable NONLAYERFILEPATH dword Normal Constant 255 - On the Call DLL Function dialog, set the following options:
- Return Value Type
Select dword - Returned Variable
Enter RETVAL - Keep DLL loaded in memory after returning from function
Select this option
- Return Value Type
- Click OK on the Call DLL Functions dialog.
- Complete the top portion of the Call DLL Function dialog:
- Double-click the Call DLL Function action to call a Microsoft .DLL to perform the
drive mapping.- Complete the top portion of the Call DLL Function dialog:
- DLL Pathname
Enter %SYS32%\kernel32.dll - Function Name
Enter GetFileAttributesA - Call a function with variable parameter list
Select this option
- DLL Pathname
- On the Call DLL Function dialog, click Add. Complete the DLL Parameter
Settings dialog that appears and click OK:- Parameter Type
Select string pointer - Passing Type
Select Normal - Value Source
Select Variable - Variable Name
Enter NONLAYERFILEPATH
The parameter is added to the list on the Call DLL Function dialog.
- Parameter Type
- On the Call DLL Function dialog, set the following options:
- Return Value Type
Select long - Returned Variable
Enter RETVAL
- Return Value Type
- Click OK on the Call DLL Functions dialog.
- Complete the top portion of the Call DLL Function dialog:
- Double-click the If Statement action, complete its dialog, and click OK:
- If Variable
Enter RETVAL - operator drop-down list (unnamed)
Select Not Equal - The Value
Enter -1
- If Variable
- Double-click the Activate SVS Layer action:
- Layer GUID
Enter %LAYERGUID% - Return variable
Enter RETVAL
- Layer GUID
- Add an Else Statement action.
- Double-click the Deactivate SVS Layer action, complete its dialog, and click OK:
- Layer GUID
Enter %LAYERGUID% - Return variable
Enter RETVAL - Force running processes to terminate
Select this option
- Layer GUID
- Add an End Statement action to close the condition block.
- Double-click the Find Next SVS Layer action, complete its dialog, and click OK:
- Layer GUID Variable
Enter LAYERGUID - Return variable
Enter RETVAL
- Layer GUID Variable
- Add an End Statement action to close the condition block.
- Save and compile the script.
- If you have Firefox installed as a layer on your computer, click Run at the bottom of the Script Editor window to run the script.
If you don't have the Firefox layer installed, you can download it here. Because this script activates Firefox and deactivates any other layers, deactivate Firefox and, if possible, activate at least one other layer before you run the script. You can then see if the script works correctly.
Your completed script should look like this without the comments:
Figure 2
Finding a Layer by Finding One of Its Registry Keys
If you do not know the name of a virtual software layer, you can create a WiseScript that finds the layer's GUID by finding one of its registry keys. In the script, you specify the registry key you want to find in the layer. You then add script that iterates through all the layers on a computer. The script uses three Call DLL Function actions to find the registry key and the layer's GUID.
The following procedure creates a sample script that finds the GUID for the Firefox layer by finding a registry key in the Firefox installation. It has a script action that activates Firefox and another script action that deactivates any other layers. The complete sample script with comments is listed below.
This script was created for Firefox version 1.5.0.6. You may need to modify the script for other versions.
To create the sample script
- Open your WiseScript product.
- If a previous WiseScript opens, select File menu > New.
If the New Installation File dialog appears, select Blank Script and click OK. - Double-click the Set Variable action, complete its dialog, and click OK:
- Variable
Enter REGSUBKEY - New Value
Enter Software\Mozilla\Mozilla
- Variable
- Double-click the Set Variable action, complete its dialog, and click OK:
- Variable
Enter REGVALUENAME - New Value
Enter CurrentVersion
- Variable
- Double-click the Set Variable action, complete its dialog, and click OK:
- Variable
Enter REGSEARCHVALUE - New Value
Enter 1.7.5
- Variable
- Double-click the Set Variable action, complete its dialog, and click OK:
- Variable
Enter REGROOT - New Value
Enter 2147483650
- Variable
- To begin iterating through all layers whether they are active or not, double-click the Find First SVS Layer action, complete its dialog, and click OK:
- Layer GUID Variable
Enter LAYERGUID - Return Variable
Enter RETVAL
- Layer GUID Variable
- Double-click the While Statement action, complete its dialog, and click OK:
- While Variable
Enter RETVAL - operator drop-down list (unnamed)
Select Equals - The Value
Enter 0
- While Variable
- Double-click the Set Variable action, complete its dialog, and click OK:
- Variable
Enter REGKEY
- Variable
- Double-click the Set Variable action, complete its dialog, and click OK:
- Variable
Enter REGVALUE
- Variable
- Double-click the Set Variable action, complete its dialog, and click OK:
- Variable
Enter REGVALUELEN - New Value
Enter 255
- Variable
- Double-click the Call DLL Function action to call an SVS .DLL to get the full non-layer path.
- Complete the top portion of the Call DLL Function dialog:
- DLL Pathname
Enter %SYS32%\fsllib32.dll - Function Name
Enter FSL2RegOpenKeyEx - Call a function with variable parameter list
Select this option
- DLL Pathname
- On the Call DLL Function dialog, click Add for each parameter in the following table, complete the DLL Parameter Settings dialog, and click OK. Enter the parameters in the order they are listed.
Parameter Type Passing Type Value Source Variable Name string pointer Normal Variable LAYERGUID dword Normal Variable REGROOT string pointer Normal Variable REGSUBKEY dword Normal Constant 0 dword Normal Constant 131097 dword pointer Normal Variable REGKEY - On the Call DLL Function dialog, set the following options:
- Return Value Type
Select dword - Returned Variable
Enter RETVAL - Keep DLL loaded in memory after returning from function
Select this option
- Return Value Type
- Click OK on the Call DLL Functions dialog.
- Complete the top portion of the Call DLL Function dialog:
- Double-click the If Statement action, complete its dialog, and click OK.
- If Variable
Enter REGKEY - operator drop-down list (unnamed)
Enter Not Equal
- If Variable
- Double-click the Call DLL Function action to call an SVS .DLL to get the full non-layer path.
- Complete the top portion of the Call DLL Function dialog:
- DLL Pathname
Enter %SYS32%\fsllib32.dll - Function Name
Enter FSL2RegQueryValueEx - Call a function with variable parameter list
Select this option
- DLL Pathname
- On the Call DLL Function dialog, click Add for each parameter in the following table, complete the DLL Parameter Settings dialog, and click OK. Enter the parameters in the order they are listed.
Parameter Type Passing Type Value Source Variable Name dword Normal Variable REGKEY string pointer Normal Variable REGVALUENAME dword Normal Constant 0 dword Normal Constant 0 string pointer Normal Variable REGVALUE dword pointer Normal Variable REGVALUELEN - On the Call DLL Function dialog, set the following options:
- Return Value Type
Select dword - Returned Variable
Enter RETVAL - Keep DLL loaded in memory after returning from function
Select this option
- Return Value Type
- Click OK on the Call DLL Functions dialog.
- Complete the top portion of the Call DLL Function dialog:
- Double-click the Call DLL Function action to call an SVS .DLL to get the full non-layer path.
- Complete the top portion of the Call DLL Function dialog:
- DLL Pathname
Enter %SYS32%\fsllib32.dll - Function Name
Enter FSL2RegCloseKey - Call a function with variable parameter list
Select this option
- DLL Pathname
- On the Call DLL Function dialog, click Add. Complete the DLL Parameter
Settings dialog that appears and click OK:- Parameter Type
Select dword - Passing Type
Select Normal - Value Source
Select Variable - Variable Name
Enter REGKEY
The parameter is added to the list on the Call DLL Function dialog.
- Parameter Type
- On the Call DLL Function dialog, set the following options:
- Return Value Type
Select dword - Returned Variable
Enter RETVAL
- Return Value Type
- Click OK on the Call DLL Functions dialog.
- Complete the top portion of the Call DLL Function dialog:
- Add an End Statement action to close the condition block.
- Double-click the If Statement action, complete its dialog, and click OK:
- If Variable
Enter REGVALUE - operator drop-down list (unnamed)
Select Equals - The Value
Enter %REGSEARCHVALUE%
- If Variable
- Double-click the Activate SVS Layer action, complete its dialog, and click OK:
- Layer GUID
Enter %LAYERGUID% - Return variable
Enter RETVAL
- Layer GUID
- Add an Else Statement action.
- Double-click the Deactivate SVS Layer action, complete its dialog, and click OK:
- Layer GUID
Enter %LAYERGUID% - Return variable
Enter RETVAL - Force running processes to terminate
Select this option
- Layer GUID
- Add an End Statement action to close the condition block.
- Double-click the Find Next SVS Layer action, complete its dialog, and click OK:
- Layer GUID Variable
Enter LAYERGUID - Return variable
Enter RETVAL
- Layer GUID Variable
- Add an End Statement action to close the condition block.
- Save and compile the script.
- If you have Firefox installed as a layer on your computer, click Run at the bottom of the Script Editor window to run the script.
If you don't have the Firefox layer installed, you can download it here.
Because this script activates Firefox and deactivates any other layers, deactivate Firefox and, if possible, activate at least one other layer before you run the script.
You can then see if the script works correctly.
Your completed script should look like this without the comments:
Figure 3


Comments
Manage SVS Layer Central
Please look at WWW.SCENSE.NL
Scense will provide you with all the functions you need to control the layers in your environment. It even gives you additional functions like Save & Restore userdata (settings) during logon and logoff from the domain.
Next to this Scense supports global and application excludes from a central console for all your SVS applications.
Would you like to reply?
Login or Register to post your comment.