App-V 5 and Drivers

Virtualizing applications using App-V 4.X and even App-V 5 does not allow to virtualize drivers, as they are injected directly into the Windows kernel (simplified, of course). Using App-V 5 there has been new progress in easing the delivery of both driver and the application. With a few exceptions, drivers can often be easily extracted from the source-files or the installed application itself. Looking at Dymo Label Writer – you can see that there is a sub-folder within the installation directory called drivers.

image

Reviewing the contents you can see that there is an executable file named dpinst.exe and if you run dpinst.exe /?, the following help is shown.

dpinst.exe: installs and uninst alls driver packages. By default, the tool searches the current directory and tries to install all dri ver packages found.&lt;/pre&gt;<br />Usage: dpinst.exe [/U INF-file] [/S | /Q][/LM][/P][/F][/SH][/SA][/A][/PATH Path][/EL][/L LanguageID][/C][/D][/Lo gTitle Title][/SW][/? | /h | /help]<br /><br />/U INF-file    Uninstall a driver package (INF-file).<br /><br />/S | /Q        Silent (Quiet) mode. Suppresses the Device Installation Wizard and any dialogs popped-up by the operating system.<br /><br />/LM    Legacy mode. Accepts unsigned driver packages and packages with missing  files. These packages won't install on the latest version of Windows.<br /><br />/P     Prompt if the driver package to be installed is not better than the cur rent one.<br /><br />/F     Force install if the driver package is not better than the current one.<br /><br />/SH    Scans hardware for matching devices and only copies and installs those drivers for which a device is present. Only valid for Plug and Play drivers.<br /><br />/SA    Suppress the Add/Remove Programs entry normally created for each driver  package.<br /><br />/A     Install all or none.<br /><br />/PATH Path     Search for driver packages under the given path.<br /><br />/EL    Enables all languages not explicitly listed in the XML file.<br /><br />/L LanguageID          Tries to use the given language in all UI. Useful for l ocalization tests.<br /><br />/SE    Suppress the EULA.<br /><br />/C     Dump logging output to attached Console (Windows XP and above).<br /><br />/D     Delete driver binaries on uninstall.<br /><br />/SW    Suppresses the Device Installation Wizard, the operating system might s till pop-up user dialogs.<br /><br />/? | /h | /help        Shows this help.

Once you wrap up your App-V 5 package you can see that there is a file called DymoLabel Writer 8.4_DeploymentConfig.xml. This contains the setup for a package once its added to a computer and can be used to provide an elevated way of performing actions when deploying a package. Using Powershell or SCCM 2012 this deployment file can be used to provide additional configuration when deployed.

Lets leave the file intact for the most part – it contains any options that were set during sequencing as a standard sample file. Find the section;
<!– Machine Scripts Example – customize and uncomment to use machine scripts –>

Adding this;

&lt;!-- Machine Scripts Example - customize and uncomment to use machine scripts --&gt;&lt;/pre&gt;<br />&lt;MachineScripts&gt;<br /><br />&lt;AddPackage&gt;<br /><br />&lt;Path&gt;C:\media\Drivers\dpinst.exe&lt;/Path&gt;<br /><br />&lt;Arguments&gt;/s&lt;/Arguments&gt;<br /><br />&lt;Wait RollbackOnError="false" Timeout="30"/&gt;<br /><br />&lt;/AddPackage&gt;<br /><br />&lt;/MachineScripts&gt;

The script explains itself. When the package is added – it will be executed. The timeout is 30 seconds and it will not rollback the package deployment if it fails.

To add it using Powershell (SCCM does this automatically for you), fire up a Powershell console and start coding. First, allowed remotely signed scripts to run

Set-ExecutionPolicy RemoteSigned

Import the App-V Client module

Import-Module AppVClient

Add the package with the configuration file and then publish it in a globla-context

Add-AppvClientPackage '.\DymoLabel Writer 8.4.appv' -DynamicDeploymentConfiguration '.\DymoLabel Writer 8.4_DeploymentConfig.xml' | Publish-AppvClientPackage –Global

If you haven’t enabled package scripts to run, you will get this error in the App-V Operational Log;

Log Name:      Microsoft-AppV-Client/Operational<br />Source:        Microsoft-AppV-Client<br />Date:          10/15/2012 11:05:18 PM<br />Event ID:      4004<br />Task Category: Execute Embedded Scripts<br />Level:         Information<br />Keywords:      Embedded Scripting<br />User:          APPVCLIENT\AppV Win7 x86 Client<br />Computer:      appvclient<br />Description: Running machine script defined in package {2b838582-4925-4a53-99a2-0aaf216df77d} for event AddPackage. Script execution was initiated by User Account: 'S-1-5-21-1739582198-759874057-429165515-1000'; command line: 'C:\media\Drivers\dpinst.exe /s'.

You can enable scripts to run for the App-V Client via Powershell;

Set-AppVClientConfiguration –EnablePackageScripts 1

This shows up under Programs and Features once we are done;

image

5 thoughts on “App-V 5 and Drivers

  1. Tz

    The example for the Dymo driver does not really explain why in this case you’re able to install a driver as opposed to typically being unable to do so. Could you clarify or point to a document explaining the limitations of installing/sequencing drivers in the App-V 5 framework?

    Thanks!

    Reply
  2. Ben De Vriese

    Hello Nicke,

    You have a typo in the last Poweshell command.
    Is “Set-AppVClientConfiguation”, should be “Set-AppvClientConfiguration”.

    Thx for the article!

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *