App-V 5.0
Windows Error: 0x2E4 with ConfigMgr 2012 R2 and App-V 5.0
If an App-V package has scripts to perform an operation, the application install may fail and show a dialog box similar to the image below.
Checking the AppEnforce.log file will reveal the error as below.
Publish-AppvClientPackage : Application Virtualization Service failed to complete requested operation.
Operation attempted: Publish AppV Package.
Windows Error: 0x2E4 – The requested operation requires elevation
Error module: Embedded Scripting. Internal error detail: 7D401E30000002E4.
Please consult AppV Client Event Log for more details.
In this case the problem is caused because the application is targeting the user and cannot execute the necessary PowerShell commands to run the script which has been embedded in the App-V package. This particular scenario utilizes a demo that I do for customers to install an application compatibility shim as per my blog post “App-V 5.0 Demo – Application Shims“. With this scripting, it’s best for the package to be globally published (i.e. targeting the computer) and not user published.
Updated 7/16/2015: As pointed out in the comments, the actual problem/solution was found. Instead of using the PublishPackage element of the UserConfig.xml script, use the AddPackage element of the DeploymentConfig.xml script. In that way the PowerShell commands have the permissions to execute.
Tips for App-V 5.0 Sequencer Configuration
When it comes to setting up a good configuration for an App-V 5.0 SP2 (or later) sequencer, the items below are typically what I like to establish. This list may not be fully complete and could be added to over time. Optionally, if you have any recommendations, please feel free to leave a comment below!
- Added a file named “ccmsetup” (no file extension) in C:\Windows, which helps prevent the ConfigMgr client from being installed
- Turn off or disable: Windows Defender, Windows Update checks, Windows Firewall, Action Center notifications, restore points, auto restart on BSOD, highlight newly installed programs, and Windows indexing/search also needs to be turned off (disable the service “Windows Search”)
- Turn on or enable: remote desktop, set the display to “best performance”, add the “Run” box on the start menu, set IE to open with a blank page (and not MSN.com), set the system tray to show all icons, task manager to hide when minimized, desktop background to solid white color (makes for cleaner screen snips), and change the IE taskbar shortcut from the x64 app version to instead use the x86 app
- Install additional software KB2775511 (for Win7 SP1), WMF 4.0, KB2533623, Microsoft Office, the latest version of Hyper-V integration services, and the current supported version (in the business) of Internet Explorer*
- Install all Windows updates
- Ensure there was no random startup software either in the Run/RunOnce registry keys and the Startup folder
* Note that as of January 12, 2016, IE 11 will be the minimum supported browser version for Win7 and newer operating systems. So if you haven’t started planning yet, it’s a good idea to begin soon.
App-V 5.0 – get .appv package file
If using standalone AppV 5.0 infrastructure, use the following SQL query against your AppVManagement database to retrieve the list of packages and their corresponding .appv file/path.
Select Name, PackageURL From dbo.PackageVersions Order By Name
App-V 5.0 bulk add and publish applications
Piggybacking on Aaron Parker’s blog post for App-V 5 PowerShell One Liners – Adding and Publishing App-V Server Packages, I’ve extended the usage of the script to parse all sub-directories of a folder to add/publish any .appv package.
$grpName = "lab\Domain Users" $appContentShare = "\\appv5-server\content-share" # Get the list of AppV files Set-Location $appContentShare $filesList = get-childitem $_.DirectoryName -include *.appv -recurse # Bulk import/publish/grant access ForEach ($file in $filesList) { Import-AppvServerPackage -PackagePath $filesList | Publish-AppvServerPackage -Verbose | Grant-AppvServerPackage -Groups $grpName -Verbose }
And that’s all it takes!
App-V 5.0 Script to Update Environment Path
The following script can be used as an example for to update the Windows system Environment variable PATH to include the root of the virtual file system for the package. The script can be included as part of an App-V 5.0 dynamic configuration file (e.g. DeploymentConfig.xml).
@echo off :: This script is intended to be embeded in an App-V 5.0 package for :: the purpose of adding .exe files into command path. :: It will retrive the current working directory of the script folder, :: change the value from ending with \Scripts to \Root, and finally :: update the PATH environment variable to include the directory path. cls :: Get the path of this script set newpth=%~dp0 :: Change the value from \Scripts to \Root set newpth=%newpth:scripts=Root\bin% echo NEWPTH = %newpth% :: Get existing PATH variable for /F "tokens=2* delims= " %%f IN ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Path ^| findstr /i path') do set OLD_SYSTEM_PATH=%%g :: Determine if the new path already exists echo.%OLD_SYSTEM_PATH% | findstr /i /c:%newpth% 1>nul If errorlevel 1 ( echo NEWPTH pattern not found setx PATH "%path%;%newpth%;" -m ) Else ( echo NEWPTH pattern found, skipping ) :: for troubleshooting, uncomment the pause below :: pause
Then use this within the UserConfig of the DeploymentConfig.xml
<UserScripts> <PublishPackage> <Path>cmd.exe</Path> <Arguments>/c [{AppVPackageRoot}]\..\Scripts\newpath.bat</Arguments> <Wait RollbackOnError="true" Timeout="60"/> </PublishPackage> </UserScripts>
App-V 5.0 Demo – Global scripting / Install Hardware Drivers
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.
- 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.
- 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
- 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
- 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>
- Add the package into the App-V 5.0 console as per standard process. Follow my guideline on how to “activate” the DeploymentConfig scripts.
- 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!
Additionally, you can see in the App-V operational events where that the .bat script was executed from within the package.
App-V 5.0 Demo – User scripting / StartProcess
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.
- 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.
- 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;quot;&amp;amp;amp;amp;amp;amp;quot; write-host $vfsPath Set-Location $vfsPath Invoke-Item "Sudoku Rules.txt"
- 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>
- 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!
Furthermore, the App-V operational events show execution of the script.
App-V 5.0 Standalone – How to Activate Deployment Scripts
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.
- In your the App-V web console, locate the package and click Edit
- 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 UserScripts - On the Default Configuration pane, select Advanced from the left-side menu, the click Import and Overwrite this Configuration
- 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). - In the window, select to Overwrite the configuration
App-V 5.0 Standalone – How to Activate User Scripts
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.
- In your the App-V web console, locate the package and click Edit
- For the deployed user group, select the drop-down option for “Custom” and click Edit
- On the Custom Configuration pane, select Advanced from the left-side menu, the click Import and Overwrite this Configuration
- 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). - In the window, select to Overwrite the configuration
PowerShell Script to test App-V 5.0 Packages
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:
- pkgPath – the UNC to the AppV files
- pkgAppV – the name of the .app file
- pkgXML – the name of the .xml file
- 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</pre> # 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 }