In my previous blog I had posted about a simple registry tweak to publish packages globally/User by just right clicking and selecting the option. But in that method, it will not use the dynamic configuration file. And so I have covered how to do that in this blog.
copy the below code in notepad and save it in .reg format. After saving, double click on it and register the keys.
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\.appv] @="appvex" [HKEY_CLASSES_ROOT\appvex] [HKEY_CLASSES_ROOT\appvex\shell] [HKEY_CLASSES_ROOT\appvex\shell\Publish Globally] @="&Publish Globally" [HKEY_CLASSES_ROOT\appvex\shell\Publish Globally\command] @="cmd /c start /b /wait powershell.exe -nologo -ExecutionPolicy bypass -file \"c:\\Publish globally.ps1\" \"%1\"" [HKEY_CLASSES_ROOT\appvex\shell\Publish to User] @="Publish to &User" [HKEY_CLASSES_ROOT\appvex\shell\Publish to User\command] @="cmd /c start /b /wait powershell.exe -nologo -ExecutionPolicy bypass -file \"c:\\Publish to user.ps1\" \"%1\""
Publish Globally:
Copy the below code in a notepad and save it as Publish globally.ps1. Place this file in C:\ drive. If you are planning to keep it elsewhere, then edit the registry entry accordingly.
#Import App-V Client Module Import-Module AppvClient #Enable execution of scripts Set-AppvClientConfiguration -EnablePackageScripts 1 #get appvfile $appvfile = "$args" Write-Host $appvfile #get appv file location $appvlocation = $appvfile.lastindexof("\") $location = $appvfile.substring(0,$appvlocation) Write-Host $location Write-Host "Path is valid = $(Test-Path $location)" Set-Location $location #get _Deploymentconfig file ForEach ($file in "$location") { $Name=Get-ChildItem $file for ($i = 0; $i -lt $Name.count; $i++) { if ($Name[$i].Extension -eq ".xml") { $xmlFileName = $Name[$i].FullName if ($xmlFileName.contains("_DeploymentConfig")) { $deploymentconfigfile = $xmlFileName Write-Host "$deploymentconfigfile" } } } Add-AppvClientPackage -path $appvfile -DynamicDeploymentConfiguration "$deploymentconfigfile" | Publish-AppvClientPackage -Global | Mount-AppvClientPackage }
Publish to User:
Copy the below code in a notepad and save it as Publish to user.ps1. Place this file in C:\ drive. If you are planning to keep it elsewhere, then edit the registry entry accordingly.
#Import App-V Client Module Import-Module AppvClient #Enable execution of scripts Set-AppvClientConfiguration -EnablePackageScripts 1 #get appvfile $appvfile = "$args" Write-Host $appvfile #get appv file location $appvlocation = $appvfile.lastindexof("\") $location = $appvfile.substring(0,$appvlocation) Write-Host $location Write-Host "Path is valid = $(Test-Path $location)" Set-Location $location #get _userconfig file ForEach ($file in "$location") { $Name=Get-ChildItem $file for ($i = 0; $i -lt $Name.count; $i++) { if ($Name[$i].Extension -eq ".xml") { $xmlFileName = $Name[$i].FullName if ($xmlFileName.contains("_UserConfig")) { $UserConfigfile = $xmlFileName Write-Host "$UserConfigfile" } } } Add-AppvClientPackage -path $appvfile | Publish-AppvClientPackage -DynamicUserConfigurationPath "$UserConfigfile"| Mount-AppvClientPackage }
Context Menu Preview:
When you right click any .appv file, it will show the below two context menu shortcuts.If you want to publish globally along with the deploymentconfig file then click on Publish Globally and to publish to a user along with the Userconfig file then click on Publish to User.