I had success to make a program selectable (and use default) in open withOpen With
context menu. The solution above is working well but usually users don't want to use context menu at every time instead associate to file type. As we are in a managed environment and not automatically associate anything via SCCM deployment therefore a small workaround could be:
First explored some reason even our app in virtual HKCR\Applicatons\something.exeHKCR\Applicatons\something.exe
could not be selected from open withOpen With
after published to user. I made the following powershellPowerShell script and the trick will be done when running at add-package as run in machine-context and put necessary data into native registry. Yes, this script could be easier and more transparent, but for testing purposes should be fine for first shot:
$ConnectorScriptRootPath = Split-Path -Path ((Get-Variable MyInvocation).Value).MyCommand.Path -Parent
$ConnectorRootPath = Split-Path -Path $ConnectorScriptRootPath -Parent
$OWExecutable = """" + $ConnectorRootPath + "\Root\VFS\ProgramFilesX64\VLC\vlc.exe" + """" + " --started-from-file " + """" + "%1" + """"
New-Item -Path HKLM:\Software\Classes\Applications -Name vlc.exe –Force
New-Item -Path HKLM:\Software\Classes\Applications\vlc.exe -Name shell –Force
New-Item -Path HKLM:\Software\Classes\Applications\vlc.exe\shell -Name Open –Force
New-Item -Path HKLM:\Software\Classes\Applications\vlc.exe\shell\Open -Name Command –Force
New-ItemProperty -Path HKLM:\Software\Classes\Applications\vlc.exe -Name "FriendlyAppName" -Value "VLC Media Player" -PropertyType String -Force
Set-Item -Path HKLM:\Software\Classes\Applications\vlc.exe\shell\Open -Value "Play with VLC Media Player" -Force
Set-Item -Path HKLM:\Software\Classes\Applications\vlc.exe\shell\Open\Command -Value $OWExecutable -Force
$ConnectorScriptRootPath = Split-Path -Path ((Get-Variable MyInvocation).Value).MyCommand.Path -Parent
$ConnectorRootPath = Split-Path -Path $ConnectorScriptRootPath -Parent
$OWExecutable = """" + $ConnectorRootPath + "\Root\VFS\ProgramFilesX64\VLC\vlc.exe" + """" + " --started-from-file " + """" + "%1" + """"
New-Item -Path HKLM:\Software\Classes\Applications -Name vlc.exe –Force
New-Item -Path HKLM:\Software\Classes\Applications\vlc.exe -Name shell –Force
New-Item -Path HKLM:\Software\Classes\Applications\vlc.exe\shell -Name Open –Force
New-Item -Path HKLM:\Software\Classes\Applications\vlc.exe\shell\Open -Name Command –Force
New-ItemProperty -Path HKLM:\Software\Classes\Applications\vlc.exe -Name "FriendlyAppName" -Value "VLC Media Player" -PropertyType String -Force
Set-Item -Path HKLM:\Software\Classes\Applications\vlc.exe\shell\Open -Value "Play with VLC Media Player" -Force
Set-Item -Path HKLM:\Software\Classes\Applications\vlc.exe\shell\Open\Command -Value $OWExecutable -Force
And I place this file into script directory: [{AppVPackageRoot}]..\Scripts\VLC_AddPackage.ps1
[{AppVPackageRoot}]\..\Scripts\VLC_AddPackage.ps1
After sequenced and in package editor I exported the manifest file and opened with App-V Manifest Editor from TMUrgent solution. In manifest editor I went to scripts/machine scripts/Add-packagescripts/machine scripts/Add-package
and set:
Path: PowerShell.exePowerShell.exe
Arguments: -executionpolicy bypass [{AppVPackageRoot}]..\Scripts\VLC_AddPackage.ps1
wait-executionpolicy bypass [{AppVPackageRoot}]\..\Scripts\VLC_AddPackage.ps1
wait: true
Timeouttrue
Timeout:3030
Be careful with AppvEnvvarsAppvEnvvars
have to be as above: [{AppVPackageRoot}][{AppVPackageRoot}]
Be careful with wait,wait
: if script will wentgoes wrong and there areis no timeout then you could be in an unwanted situation.
After adding the package (and publishing) the package, it can be browsed from more applicationapplications in open WithOpen With
and the user can be set it up as a default one.
Here not mentioned but take care when removing the packagepackage; there should be another script which removes entries added when publishing.
Hope this helps,.