I have a self-extracting WinRar archive set up to run a powershell script upon completion. The script will launch, but specific commands do not give expected results.
In particular, I have the following command to find the installation path of an installed game (Risk of Rain 2).
Get-ChildItem HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall | % { Get-ItemProperty $_.PsPath } | Where-Object {$_.DisplayName -like 'Risk of Rain 2'} | Select InstallLocation -ExpandProperty InstallLocation
When running the script by itself, I get the install path as expected.
F:\SteamLibrary\steamapps\common\Risk of Rain 2
When the script is launched (either before or after extraction), the command seems to run, but outputs nothing.
In testing, I removed everything but the following:
Get-ChildItem HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall | % { Get-ItemProperty $_.PsPath }
This still works, outputting a list of installed applications. When I add the pipe to the "Where-Object" portion, it starts to fail.
My only guess is that WinRar is starting the scripts with some other parameters set.
I tried having Winrar start a .bat that will then run the .ps1 file, but had the same result. Same goes for running the archive as an administrator.
Is something funky with my powershell script, or am I just missing something with how Winrar handles things?
Thanks!