Deploying and Importing SVS Layers by MSI

Deploying and Importing SVS Layers by MSI

Most of the time I install software by Group Policies in the Active Directory. But I encountered a few obstacles that forced me to blaze a new trail. Here's how I use WiseScripts to take care of some of my software installation woes.

Rethinking My Strategy

  • SVS does not have an interface yet to distribute layers to the workstations in GPOs.
  • Wise Package Studio only has an SVS Wrapper for MSIs and not the other way around.

Those are the reasons I tried to make a wrapper myself. This is the first version of it.

  • It looks for an Layername, places a VSA on the workstation and imports it into SVS.
  • It also can activate the new layer at startup and/or activate the layer after the installation.
  • The installation shows up in the Add/Remove program and will delete the layer when you un-install the MSI.

MSIs aren't made to distribute and install SVS Layers. There are no native functions for it. So I use embedded WiseScripts to make the install happen. The WiseScripts communicate with the MSI by MSI Properties.

The attached zip file contains 2 WSIs, their corresponding MSIs and all the (compiled) WiseScripts.

SVSInstall.wsi - Template wsi for installing an exported layer file (vsa).
SVSInstall-demo.wsi - Demo version of the SVSInstaller, installing an small layer.

If you use the template, place only one file (.VSA) in the MSI. You can choose your own installdirectory for the .VSAs.
After you put the file into the MSI, you should set the properties in the propertytable.

The following properties are used in the installation:

_VSANAME (string) Should be the name and extension of the VSA being installed
_LAYERNAME (sting) Name of the layer being used inside the VSA and is the name to search for to see if the application is already installed into SVS
_OVERWRITELAYER (0/1) 1 if vsa should be imported if layer already exist.
_ACTIVATEONINSTALL (0/1) 0 if the msi shouldn't activate the layer, 1 if it should activate it
_ACTIVATEONSTARTUP (0/1) 1 if the layer should be auto started, else value of 0.
_IMPORTSUCCESS (number) Not in use yet
_LayerFound (0/1) Will be set by the wse SearchLayer if the layername is already available in SVS
_LayerGuid (string) not in use yet

The first WiseScript that will be run is the SearchLayer.wse. This script runs before showing the GUI.

Set Variable LAYERFOUND to 0
Set Variable LAYERNAME to Nothing
Get Windows Installer Property _LAYERNAME into LAYERNAME
Find SVS Layer GUID for "%LAYERNAME%"
If LAYERFOUND Not Equal "{00000000-0000-0000-0000-000000000000}" then
Set Windows Installer Property _LayerFound to 1
End

This script reads the _LAYERNAME property from the MSI, puts it in his properties and searches for it. If the layer is found sets the MSI Property _LayerFound to 1. The layer is found when the GUID of the layer is not equal to {00000000-0000-0000-0000-000000000000}.

After searching for the layer we have to find out if the VSA needs to be imported in SVs.
If the layer is not found or when the layer is found and the _OVERWRITELAYER property is set to 1, the vsa needs to be imported.
Here the ImportOverwrite.wse is kicking in.

Set Variable VSA_NAME to Nothing
Set Variable VSA_PATH to Nothing
Set Variable LAYERGUID to 0
Get Windows Installer Property INSTALLDIR into VSA_PATH
Get Windows Installer Property _VSANAME into VSA_NAME
Import SVS Layer from "%VSA_PATH%%VSA_NAME%"
Set Windows Installer Property _LayerGuid to %LAYERGUID%

This script reads the installationdirectory from the MSI and the filename of the VSA and uses the SVSImport function to import the layer into SVS.
In the import-function is the option 'Overwrite if layer already exists' enabled.

After this script is run, there are two optional scripts running. Both are almost identical, only addressing an different function on the end of the script.

Set Variable LAYERNAME to Nothing
Set Variable LAYERGUID to Nothing
Get Windows Installer Property _LAYERNAME into LAYERNAME
Find SVS Layer GUID for "%LAYERNAME%"
Activate SVS Layer GUID: %LAYERGUID%

First it is searching the Layer GUID by the Layername property. After finding the GUID it calls the function to enable it directly after importing or (in StartupActivateLayer.wse) to set the 'Start layer automatically' option in SVS.

All those WiseScripts are put into the MSI. To prevent it from importing the layer while un-installing the application, you have to add the 'if NOT REMOVE~="All"' statement. I've put the scripts in the Execute Deferred section, just after the InstallFiles sequence. The code looks like this:

If NOT REMOVE~="All" then
 If _LayerFound="0" OR (_LayerFound="1" AND _OVERWRITELAYER="1") then
  Run WiseScript from Installation .\WSE\ImportOverwrite.Exe Command Line /s (InstallLayer)
  If _ACTIVATEONSTARTUP="1" then
   Run WiseScript from Installation .\WSE\StartupActivateLayer.exe Command Line /s (ActivateOnStartup)
  End
  if _ACTIVATEONINSTALL="1" then
   Run WiseScript from Installation .\WSE\InstallActivateLayer.exe Command Line /s (ActivateLayer)
  End
 End
End

All WiseScripts are being called with the /s to silent the execution.

The last function in this version is the remove function. When you remove this MSI from add/remove programs, the layer will be deleted too.

To get this working there is another WiseScript.

Set Variable LAYERNAME to Nothing
Set Variable LAYERGUID to Nothing
Get Windows Installer Property _LAYERNAME into LAYERNAME
Find SVS Layer GUID for "%LAYERNAME%"
Deactivate SVS Layer GUID: %LAYERGUID%
Delete SVS Layer "%LAYERGUID%"

This one first searches for the LayerGuid. When found, it first de-activates the layer, closing all programs in that layer.
After de-activating it removes the layer from SVS.

This code is placed within the MSI, just before the Removefiles-sequence. Looking like this:

If REMOVE~="All" then
 Run WiseScript from Installation .\WSE\DeleteLayer.exe Command Line /s (RemoveLayer)
end if

As my time is limited, I cannot go deeper into the code of this MSI. You are free to use the template I made, learn from it, make enhancements etc.

If you add new functions, please let me know and place the new version back on Juice or let me place it.

Things I plan to change in the future:

  • Delete VSA after importing it into the layer, but keep the MSI in add/remove programs
  • Read status of importing and activating the layer, stop the installation when the import wasn't succesfull and rollback the installation.
  • Automaticly detect vsa-filename (so _VSANAME wouldn't be necessary anymore)
  • Automaticly detect layername from vsa-file, but I think that will be impossible atm.
License: AJSL
By clicking the download link below, you agree to the terms and conditions in the Altiris Juice Software License
Support: User-contributed tools on the Juice are not supported by Altiris Technical Support. If you have questions about a tool, please communicate directly with the author by visiting their profile page and clicking the 'contact' tab.
3.923075
Average: 3.9 (13 votes)
AttachmentSize
SVSinstaller.zip2.09 MB