change a registry value for a AppVPackage

Hello,

I want to change a registry value for a AppVPackage by using below commands, but it’s not working. Any idea why?

$AppVName = Get-AppvClientPackage -PackageId ef1af223-8cc4-4622-a8c2-cd5af4308d05
$AppVName
Start-AppvVirtualProcess -AppvClientObject $AppVName cmd.exe
set-itemproperty HKCU:\Software\FRS\FiRE\Defaults JREPath C:\Program Files (x86)\Java\jre1.8.0_231

I have no experience with this. I guess you have to run it under the cmd process. Or use reg.exe instead.

Start-AppvVirtualProcess -AppvClientObject $AppVName cmd.exe '/c powershell set-itemproperty HKCU:\Software\FRS\FiRE\Defaults JREPath "C:\Program Files (x86)\Java\jre1.8.0_231"'

Or this? I’m not sure if the argumentlist can be an array or a space seperated string, or maybe both work, if it’s like start-process:

Start-AppvVirtualProcess -AppvClientObject $AppVName -filepath powershell -argumentlist set-itemproperty, HKCU:\Software\FRS\FiRE\Defaults, JREPath, "C:\Program Files (x86)\Java\jre1.8.0_231"
set-itemproperty HKCU:\Software\FRS\FiRE\Defaults JREPath C:\Program Files (x86)\Java\jre1.8.0_231

The immediate problem is that the spaces in C:\Program Files (x86)\Java\jre1.8.0_231 are causing PowerShell to be unable to interpret your input parameters. You should always wrap paths in quotes so that the shell doesn’t parse special characters and spaces:

set-itemproperty 'HKCU:\Software\FRS\FiRE\Defaults' JREPath 'C:\Program Files (x86)\Java\jre1.8.0_231'

Also, for the sake of safety when editing the registry, you should specify each parameter explicitly rather than using the shorthand method. Every tutorial about registry editing with PowerShell, and the documentation for Set-ItemProperty, shows the full parameter names being typed out.

Set-ItemProperty -Path 'HKCU:\Software\FRS\FiRE\Defaults' -Name 'JREPath' -Value 'C:\Program Files (x86)\Java\jre1.8.0_231'

It pays to be careful with the registry.

Note that set-itemproperty has a -Type parameter with registry paths, but it’s not documented in an obvious place.

Ok, the below ‘Set-ItemProperty’ command is working, but the registry change is not done in the registry for the AppVpackage rather in the normal window registry. How can I load the virtual registry appV package before the ‘Set-ItemProperty’ command?

 

I think this is what you’re looking for: How to Configure the App-V Client Registry Settings by Using the Command Line, and specifically this part:

Important On a 64-bit computer, the keys and values described in the following sections will be under HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\SoftGrid\4.5\Client
I think the registry subkeys for the AppV client will be listed under that path, but I don't have an AppV environment to check it. You'll have to look through your own registry to verify.