From fb7a85ec81f2766562b42bd91fc80df94e4738e7 Mon Sep 17 00:00:00 2001 From: Stefan Markovic <57057282+stefansjfw@users.noreply.github.com> Date: Wed, 5 Jun 2024 12:10:08 +0200 Subject: [PATCH] [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 --- installer/PowerToysSetupCustomActions/CustomAction.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/installer/PowerToysSetupCustomActions/CustomAction.cpp b/installer/PowerToysSetupCustomActions/CustomAction.cpp index de366e5079..064976c99e 100644 --- a/installer/PowerToysSetupCustomActions/CustomAction.cpp +++ b/installer/PowerToysSetupCustomActions/CustomAction.cpp @@ -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());