Month: February 2014

App-V 5.0 Demo – Global scripting / Install Hardware Drivers

Posted on Updated on

This is the walk-through for demo #4 from my Microsoft Master webcast on App-V 5.0 scripting.  For the full webcast information, visit https://t3chn1ck.wordpress.com/2014/02/03/playback-of-microsoft-master-app-v-5-0/.

This demo is on scripting the install of hardware drivers (HP printer) when an App-V package is published to a system.  For this example, I am using the standalone App-V infrastructure, not ConfigMgr 2012 R2.

  1. As you may already know, App-V does not capture drivers as part of the package.  So I’ve obtained the driver files specific to that device separately to be ready for use during my sequencing process.appv-driver-demo01
  2. Furthermore in this case, I’ve also created a simple .bat script to perform the install of the drivers since it has a longer more complex command line.  I named that file DriverInst.bat which has the following command.  Note that as part of the command line, I am giving it a custom name of the printer as “HP Univeral AppV”.
    "%~dp0Install.exe" /q /h /npf /dst /smLPT1 /n"HP Univeral AppV", 1, true
    
  3. In this instance, as part of the sequencing process, I have used a script that A) installs the software then B) makes a local copy of those driver files.  In this way, the sequencer ‘detects’ the files and adds them all as part of the package VFS.Important: since I am embedding the driver files as part of the VFS, know that this example will not work well for instances where the package is set to stream from the server.  Rather it will only work on cached copies with the full files.  If you have a streaming server, then the all driver files/installers will need to be added into the scripts folder.
    :: Install directory - C:\Program Files (x86)\HP\HP Officejet 6700
    "%~dp0OJ6700_Basicx64_1315\HP-DQEX5.exe"
    
    xcopy "%~dp0HPUPD\*" "C:\Program Files (x86)\HP\UPD\*" /YES
    
    :: Pause to verify completion
    pause
    
  4. Next we need to add the package to install as part of the DeploymentConfig.xml
    <MachineScripts>
       <PublishPackage>
          <Path>cmd.exe</Path>
          <Arguments>/c [{AppVPackageRoot}]\VFS\ProgramFilesX86\HP\UPD\DriverInst.bat</Arguments>
          <Wait RollbackOnError="true" Timeout="120"/>
       </PublishPackage>
    </MachineScripts>
    
  5. Add the package into the App-V 5.0 console as per standard process.  Follow my guideline on how to “activate” the DeploymentConfig scripts.
  6. For the webcast demo, it was PC targeted (not user) for Global publishing.  In order to quickly have the deployment synchronized with the system, we need to run the below PowerShell commands.
    Note: If UAC is enabled for the system, this will need to execute in an elevated command shell.

    Get-AppvPublishingServer | Sync-AppvPublishingServer -Global
    

Once the package is added to the system, we now show our “App-V” printer software was added as well as the printer hardware!
appv-driver-demo02

Additionally, you can see in the App-V operational events where that the .bat script was executed from within the package.
appv-driver-demo03

Advertisement

App-V 5.0 Demo – User scripting / StartProcess

Posted on Updated on

This is the walk-through for demo #3 from my Microsoft Master webcast on App-V 5.0 scripting.  For the full webcast information, visit https://t3chn1ck.wordpress.com/2014/02/03/playback-of-microsoft-master-app-v-5-0/.

This demo is on scripting for a process to run when a user launches the application.  I’m using the game of Sudoku (obtained from SourceForge) and when it is launched by the user, it opens a text file on the “rules” of the game.  For this example, I am using the standalone App-V infrastructure, not ConfigMgr 2012 R2.

  1. The package has already been sequenced.  It’s just a simple set of files (and the main .exe) that I copied into the Program Files directory.  After sequencing, I added the PowerShell script to perform the operation.appv-sudoku-demo01
  2. The PowerShell script will obtain it’s current working directory and then execute the text file specified.
    
    function Get-ScriptDirectory {
      $Invocation = (Get-Variable MyInvocation -Scope 1).Value
      Split-Path $Invocation.MyCommand.Path
    }
    
    $vfsPath = Join-Path (Get-ScriptDirectory) &amp;amp;amp;amp;amp;amp;amp;quot;&amp;amp;amp;amp;amp;amp;amp;quot;
    write-host $vfsPath
    
    Set-Location $vfsPath
    Invoke-Item "Sudoku Rules.txt"
    
  3. In the UserConfig.xml we define that whenever Sudoku.exe is launched, then App-V will execute powershell.exe with the command line to run our .ps1 script.
    <UserScripts>
    <StartProcess RunInVirtualEnvironment="false">
    <Path>powershell.exe</Path>
    <Arguments>-ExecutionPolicy Bypass -File "[{AppVPackageRoot}]\..\Scripts\OpenRules.ps1"</Arguments>
    <Wait RollbackOnError="true"/>
    <ApplicationId>[{AppVPackageRoot}]\Sudoku.exe</ApplicationId>
    </StartProcess>
    </UserScripts>
    
  4. Now add the package into the App-V console and assign to a user group as per standard process.  Then follow my guideline on how to activate the custom UserConfig scripts.  Finally, with the test user, update the App-V client so that Sudoku becomes available.

Once Sudoku is launched, the PowerShell script will very quickly execute (so fast that I cannot capture a screen shot).  But we will have the text file open with rules for learning how to play the game!

appv-sudoku-demo02

Furthermore, the App-V operational events show execution of the script.

appv-sudoku-demo03

App-V 5.0 Standalone – How to Activate Deployment Scripts

Posted on Updated on

This is the walk-through in preparation for demonstrations from my Microsoft Master webcast on App-V 5.0 scripting.  For the full webcast information, visit https://t3chn1ck.wordpress.com/2014/02/03/playback-of-microsoft-master-app-v-5-0/.

This demo will show how to “activate” a deployment script (which may contain either user or global/PC scripts) that you may have added to the DeploymentConfig.xml of an App-V package.

  1. In your the App-V web console, locate the package and click Editappv-dep-scripts01
  2. For the deployed user or computer group, click Edit Default Config
    Note: do not select the drop-down option for “Custom” as this is only for activating UserScriptsappv-dep-scripts02
  3. On the Default Configuration pane, select Advanced from the left-side menu, the click Import and Overwrite this Configurationappv-dep-scripts03
  4. Locate and open the DeploymentConfig.xml
    Important: due some irregularities with Silverlight, after opening the XML, the console may revert back to the main package administration pane.  You’ll need to navigate back to the Advanced configuration (e.g. repeat steps 1-3 above).appv-dep-scripts04
  5. In the window, select to Overwrite the configurationappv-userscripts05

App-V 5.0 Standalone – How to Activate User Scripts

Posted on

This is the walk-through in preparation for demonstrations from my Microsoft Master webcast on App-V 5.0 scripting.  For the full webcast information, visit https://t3chn1ck.wordpress.com/2014/02/03/playback-of-microsoft-master-app-v-5-0/.

This demo will show how to “activate” a user script that you may have added to the UserConfig.xml of an App-V package.

  1. In your the App-V web console, locate the package and click Edit

    appv-userscripts01

  2. For the deployed user group, select the drop-down option for “Custom” and click Edit

    appv-userscripts02

  3. On the Custom Configuration pane, select Advanced from the left-side menu, the click Import and Overwrite this Configuration

    appv-userscripts03

  4. Locate and open the UserConfig.xml
    Important: due some irregularities with Silverlight, after opening the XML, the console may revert back to the main package administration pane.  You’ll need to navigate back to the Advanced configuration (e.g. repeat steps 1-3 above).

    appv-userscripts04

  5. In the window, select to Overwrite the configuration

    appv-userscripts05

PowerShell Script to test App-V 5.0 Packages

Posted on Updated on

I use the below PowerShell script code for testing my App-V packages prior to publishing them officially.  The top portion will add the package on the local system.  While the second portion will remove the package once my testing is complete.  For easiest execution, I use the PowerShell ISE to just run the code segments that I need.  The values to add for yourself are:

  1. pkgPath – the UNC to the AppV files
  2. pkgAppV – the name of the .app file
  3. pkgXML – the name of the .xml file
  4. pkgName – change the “Part_Of_App_Name” value to what is appropriate (such *java*)

Script updates:

  • 2/11/2014 – to handle multiple cached apps with the same name part
  • 6/16/2014 – to better generalize use of the “AppName”
# Script from https://t3chn1ck.wordpress.com

# First code adds the package
clear
$pkgPath = "\\appv5_server\share" + "\"
$pkgName = "AppName"
$pkgAppV = $pkgPath + $pkgName + ".appv"
$pkgXML = $pkgPath + $pkgName + "_DeploymentConfig.xml"
Add-AppvClientPackage -Path $pkgAppV -DynamicDeploymentConfiguration $pkgXML | Publish-AppvClientPackage&lt;/pre&gt;

# Next code removes the package but only when 
# there's one app with the name part
$pkg = Get-AppvClientPackage -Name $pkgName
Unpublish-AppvClientPackage -Name $pkg.Name
Remove-AppvClientPackage -Name $pkg.Name

# Removes multiple packages of the same name part
foreach ($pkg in Get-AppvClientPackage -Name $pkgName) {
	write-host $pkg.Name
	Unpublish-AppvClientPackage -Name $pkg.Name
	Remove-AppvClientPackage -Name $pkg.Name
}

App-V 5.0 Demo – Application Shims

Posted on Updated on

This is the walk-through for demo #2 in my Microsoft Master webcast on App-V 5.0 scripting.  For the full webcast information, visit https://t3chn1ck.wordpress.com/2014/02/03/playback-of-microsoft-master-app-v-5-0/.

This demo is on scripting the install of an application shim (for app compatibility) when an App-V package is published to a system.  For this example, I used an all time favorite software of mine … SMS Installer.

1) SMS Installer requires elevated rights in order to execute.  So if the user is a non-admin such as for my demos, they cannot use the software.  Below is the screen shot of how this gets blocked.  Even if your end users have elevated rights themselves, you may be able to use a shim to correct any UAC elevation prompts.  Additionally, you can see the “shield” on the shortcut.

smsinst-demo01

2)  Create shim with the Application Compatibility Toolkit – for more info on this process of creating a shim, visit http://spablog.ontrex.ch/2013/04/23/shims-and-app-v-5-0/

  • SMSINS32.exe
  • Run As Invoker
  • ForceAdminAccess

smsinst-demo02

3)  Add the shim into the package scripts

smsinst-demo03

4)  Update the DeploymentConfig.xml file from the package to install the shim


<MachineScripts>

<PublishPackage>

<Path>sdbinst.exe</Path>

/q "[{AppVPackageRoot}]\..\Scripts\shim.sdb"

<Wait RollbackOnError="true" Timeout="30"/>

</PublishPackage>

</MachineScripts>

5)  Add the new application into ConfigMgr and publish to user.  For more info on doing this process, see an example from https://t3chn1ck.wordpress.com/2014/02/05/app-v-5-0-demo-uninstall-a-native-application/

6)  Voila!  You can now see that the “shield” is no longer on the shortcut and that the application runs successfully!

smsinst-demo04

App-V 5.0 Demo – Uninstall a Native Application

Posted on Updated on

This is the walkthrough for demo #1 in my Microsoft Master webcast on App-V 5.0 scripting.  For the full webcast information, visit https://t3chn1ck.wordpress.com/2014/02/03/playback-of-microsoft-master-app-v-5-0/.

This demo is on uninstalling native (local) applications when an App-V package is added to a system.  For this example, I used 7-zip.

1)  First, sequence your application (7-zip).  Nothing special to do, just make sure it’s been done ;-)

2)  Create a .bat file to perform the uninstall of the software.  In this case, I just looked up GUID of the package to have msiexec perform the uninstall and added an extra step to then echo “Removed 7zip” into a text file for evidence that the script executed.  So my batch file looks like below.

Note: that you don’t have necessarily have to do this uninstall so simply as I have .. or even use a .bat script.  It could be VBScript.  Or PowerShell.  And/or include any custom checks to make sure it gets removed.  And the options go on.


MsiExec.exe /x {23170F69-40C1-2702-0920-000001000000} /qb

echo Removed 7zip >> C:\uninst_7zip.txt

3)  Save your .bat file onto a server share.  This share needs to have read, list, execute rights for all users and all computers of the domain.  In my examples, I essentially just had the share as \\server\AppV_Scripts\ which I can use for other scripts and whatnot.

4)  Edit the DeploymentConfig.xml file of the AppV package.  What we want to do is

  1. Locate the <MachineScripts> section – uncomment the blocked text so it can used
  2. Locate the <AddPackage> element and delete the rest of the elements
  3. Set the <Path> to execute cmd.exe on the system
  4. Set the <Arguments> to run the .bat file on the server; if you’re unaware /c means to cmd.exe to “run this command” which would then be your \\server\share\script.bat

<!-- Machine Scripts Example - customize and uncomment to use machine scripts -->
<MachineScripts>
<AddPackage>
<Path>cmd.exe</Path>
<Arguments>/c \\alderaan2\appv_scripts\uninst_7zip.bat</Arguments>
<Wait RollbackOnError="true" Timeout="30"/>
</AddPackage>
</MachineScripts>

5)  Now we’ll add the package into ConfigMgr as an Application.  Note that ConfigMgr will choose the most recently modified Config.xml file to use for the Deployment Type.

  1. Add a new Application7zip-demo-01
  2. Select to add an App-V 5.0 package and select the .appv file7zip-demo-02
  3. Complete the wizard
  4. Using standard ConfigMgr procedures, deploy the application to the desired user collection (or computer)
  5. Run the application from the targeted user’s Application Catalog7zip-demo-03
  6. Watch the local system as the natively installed application is removed and replaced by the AppV package is there!
  7. Then check that the C:\ for presence of the uninst_7zip.txt file thus giving further proof that script executed!

Playback of Microsoft Master App-V 5.0

Posted on Updated on

UPDATE: The playback of my webcast has been removed by BDNA and I do have a copy that can be shared.  Fortunately however, I did post step by step walkthroughs of the demos so you can still learn how to do the scripting pieces.  You will find those posts in the links below.  Furthermore, all of my posts related to App-V 5.0 can be in the category on my blog.

Playback of my presentation on App-V 5.0 Stunts Trick and Acrobatics  is now available from BDNA online.

Optionally, I’m not certain if the PDF is made available upon registration of the webcast, so feel free to obtain a PDF of the PowerPoint from my SkyDrive at https://skydrive.live.com/redir?resid=8E0D74EF1C75BFEB!17329&authkey=!ABOS2EgVLlzdWwM&ithint=file%2c.pdf