App-V 5.0

Windows Error: 0x2E4 with ConfigMgr 2012 R2 and App-V 5.0

Posted on Updated on

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.

image001

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.

Advertisements

Tips for App-V 5.0 Sequencer Configuration

Posted on Updated on

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!

  1.  Added a file named “ccmsetup” (no file extension) in C:\Windows, which helps prevent the ConfigMgr client from being installed
  2. 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”)
  3. 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
  4. 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*
  5. Install all Windows updates
  6. 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

Posted on Updated on

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

AppV5-packageversions

App-V 5.0 bulk add and publish applications

Posted on Updated on

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

Posted on

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

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

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