Installing a MSI package during App-V 5.0 Package deployment

image_pdfimage_print

Driver packages cannot be virtualized as they have to communicate directly with the hardware. So packages using a driver have never been virtualized. Until now.

With AppV 5.0 it is possible to install the driver while adding an AppV 5.0 package and to uninstall it during the removal of the AppV 5.0 package.

In this article I will show how this is done. I will use an existing package that I made earlier.

For this example I made a empty MSI package (it only contains one feature and one component) and that MSI package is installed when the AppV package is added. The details are:

The properties of the empty MSI file edited with Orca.

The properties of the empty MSI file edited with Orca.

1. Add the MSI file to the virtual application

Ths MSI file is added to the ‘Scripts’ section of the virtual application.

  • Copy the virtual package to a local drive, for example C:\AppV50Demo.
  • Open the AppV 5.0 Package.
    Open AppV Package

    Open AppV Package

  • Select ‘Edit’ to modify the virtual package.
    Select Edit

    Select Edit

  • Click [Edit]
    Click Edit.

    Click Edit.

  • Click on the tab [Package Files].
    Tab Package Files

    Tab Package Files

  • Find and select the folder ‘Scripts’.
    Click [Add].
    Add a script to the AppV 5.0 package.

    Add a script to the AppV 5.0 package.

  • Click [Browse].
    Browse

    Browse

  • Find and select the MSI file. If needed, add all the needed files, like transform and cab files.
    Select the MSI that has to be added to the AppV 5.0 package.

    Select the MSI that has to be added to the AppV 5.0 package.

  • Click [Open].
    Click Open.

    Click Open.

  • Click [Ok].
    Click Ok

    Click Ok

  • The result.
    The result.

    The result.

  • Save the package.
    Save the package

    Save the package

  • Exit the sequencer.
    Exit the sequencer.

    Exit the sequencer.

2. Edit the deployment xml file

  • Make a copy of the file ‘IgorPavlov_7Zip_9.20_ENG_2_3_4_DeploymentConfig.xml’
  • Rename that copy to ‘IgorPavlov_7Zip_9.20_ENG_2_3_4_DeploymentConfig with MSI.xml’. All the changes will be in this file.
  • Open the file ‘IgorPavlov_7Zip_9.20_ENG_2_3_4_DeploymentConfig with MSI.xml’.
  • Search for the following text:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    
        <!-- Machine Scripts Example - customize and uncomment to use machine scripts -->
        <!--
        <MachineScripts>
          <PublishPackage>
            <Path>\\server\share\foobar.exe</Path>
            <Arguments>-WithArgs</Arguments>
            <Wait RollbackOnError="true" Timeout="30"/>
          </PublishPackage>
          <UnpublishPackage>
            <Path>\\server\share\barfoo.exe</Path>
            <Arguments>-WithArgs</Arguments>
            <Wait RollbackOnError="false" Timeout="30"/>
          </UnpublishPackage>
     
          <AddPackage>
            <Path>[{PackageRoot}]\VFS\ProgramFilesX86\App\InstallDriver.exe</Path>
            <Arguments>-DriverName Printer-Visibility Northamerica</Arguments>
            <Wait RollbackOnError="true" Timeout="30"/>
          </AddPackage>
          <RemovePackage>
            <Path>[{PackageRoot}]\VFS\ProgramFilesX86\App\InstallDriver.exe</Path>
            <Arguments>-Uninstall</Arguments>
            <Wait RollbackOnError="false" Timeout="60"/>
          </RemovePackage>
        </MachineScripts>
        -->
  • And replace it by:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    
        <!-- Machine Scripts Example - customize and uncomment to use machine scripts -->
        <MachineScripts>
          <!--
          <PublishPackage>
            <Path>\\server\share\foobar.exe</Path>
            <Arguments>-WithArgs</Arguments>
            <Wait RollbackOnError="true" Timeout="30"/>
          </PublishPackage>
          <UnpublishPackage>
            <Path>\\server\share\barfoo.exe</Path>
            <Arguments>-WithArgs</Arguments>
            <Wait RollbackOnError="false" Timeout="30"/>
          </UnpublishPackage>
          -->
     
          <AddPackage>
            <Path>msiexec.exe</Path>
            <Arguments>/i TestMSI.MSI /qb! /l*v c:\windows\system32\LogFiles\Install_TestMSI.log</Arguments>
            <Wait RollbackOnError="true" Timeout="60"/>
          </AddPackage>
          <RemovePackage>
            <Path>msiexec.exe</Path>
            <Arguments>/x TestMSI.MSI /qb! /l*v c:\windows\system32\LogFiles\Uninstall_TestMSI.log</Arguments>
            <Wait RollbackOnError="false" Timeout="60"/>
          </RemovePackage>
        </MachineScripts>
  • Save the modified ‘IgorPavlov_7Zip_9.20_ENG_2_3_4_DeploymentConfig with MSI.xml’.

3. Add and publish the virtual application.

  • Copy the AppV 5.0 to a local drive, for example: C:\IgorPavlov_7Zip_9.20_ENG\1.00.00
  • Start PowerShell 3.0 as an administrator.
  • Change the security policy:
    1
    
    Set-ExecutionPolicy -ExecutionPolicy Unrestricted
  • Import all the AppV client cmdlets:
    1
    
    Import-Module AppVClient
  • check if it is possible to run scripts. It is needed to change the policy ‘EnablePackageScripts’ to 1.
    1
    
    Get-AppvclientConfiguration
  • And change the policy if needed:
    1
    
    Set-AppvclientConfiguration -EnablePackageScripts 1
  • Add and publish the virtual application:
    1
    
    Add-AppvclientPackage -Path C:\IgorPavlov_7Zip_9.20_ENG\1.00.00\IgorPavlov_7Zip_9.20_ENG_2_3_4.appv -DynamicDeploymentConfiguration "C:\IgorPavlov_7Zip_9.20_ENG\1.00.00\IgorPavlov_7Zip_9.20_ENG_2_3_4_DeploymentConfig with MSI.xml" | Publish-AppVClientPackage -Global
  • Check the logfile in C:\Windows\System32\LogFiles.
  • You will not find the application within ‘Programs and features’.
    Not in Programs and features.

    Not in Programs and features.

  • However, you can find it in the registry.
    You will find the application via regedit.

    You will find the application via regedit.

4. Remove the virtual application.

  • To uninstall the virtual application:
    1
    
    Remove-AppVClientPackage -Name *Pavlov*
  • Check the logfile in C:\Windows\System32\LogFiles.

Permanent link to this article: https://www.vroom.cc/wordpress/installing-a-msi-package-during-app-v-5-0-package-deployment/