[ARM][Installer]Fix UninstallCommandNotFoundModule not finding pwsh(#33143)

* [ARM][Installer] Fix UninstallCommandNotFoundModule

On ARM, processes does not inherit the user env variables. So, pwsh.exe could not be found from installer process.
Logic is changed to use powershell.exe to first set process' PATH env var and then trigger pwsh.exe

* address PR comments
This commit is contained in:
Stefan Markovic 2024-06-05 12:10:08 +02:00 committed by GitHub
parent a80896d51b
commit fb7a85ec81
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -608,9 +608,19 @@ UINT __stdcall UninstallCommandNotFoundModuleCA(MSIHANDLE hInstall)
hr = getInstallFolder(hInstall, installationFolder);
ExitOnFailure(hr, "Failed to get installFolder.");
#ifdef _M_ARM64
command = "powershell.exe";
command += " ";
command += "-NoProfile -NonInteractive -NoLogo -WindowStyle Hidden -ExecutionPolicy Unrestricted";
command += " -Command ";
command += "\"[Environment]::SetEnvironmentVariable('PATH', [Environment]::GetEnvironmentVariable('PATH', 'Machine') + ';' + [Environment]::GetEnvironmentVariable('PATH', 'User'), 'Process');";
command += "pwsh.exe -NoProfile -NonInteractive -NoLogo -WindowStyle Hidden -ExecutionPolicy Unrestricted -File '" + winrt::to_string(installationFolder) + "\\WinUI3Apps\\Assets\\Settings\\Scripts\\DisableModule.ps1" + "'\"";
#else
command = "pwsh.exe";
command += " ";
command += "-NoProfile -NonInteractive -NoLogo -WindowStyle Hidden -ExecutionPolicy Unrestricted -File \"" + winrt::to_string(installationFolder) + "\\WinUI3Apps\\Assets\\Settings\\Scripts\\DisableModule.ps1" + "\"";
#endif
system(command.c_str());