Skip to content

Commit fb7a85e

Browse files
authored
[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
1 parent a80896d commit fb7a85e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

installer/PowerToysSetupCustomActions/CustomAction.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -608,9 +608,19 @@ UINT __stdcall UninstallCommandNotFoundModuleCA(MSIHANDLE hInstall)
608608
hr = getInstallFolder(hInstall, installationFolder);
609609
ExitOnFailure(hr, "Failed to get installFolder.");
610610

611+
#ifdef _M_ARM64
612+
command = "powershell.exe";
613+
command += " ";
614+
command += "-NoProfile -NonInteractive -NoLogo -WindowStyle Hidden -ExecutionPolicy Unrestricted";
615+
command += " -Command ";
616+
command += "\"[Environment]::SetEnvironmentVariable('PATH', [Environment]::GetEnvironmentVariable('PATH', 'Machine') + ';' + [Environment]::GetEnvironmentVariable('PATH', 'User'), 'Process');";
617+
command += "pwsh.exe -NoProfile -NonInteractive -NoLogo -WindowStyle Hidden -ExecutionPolicy Unrestricted -File '" + winrt::to_string(installationFolder) + "\\WinUI3Apps\\Assets\\Settings\\Scripts\\DisableModule.ps1" + "'\"";
618+
#else
611619
command = "pwsh.exe";
612620
command += " ";
613621
command += "-NoProfile -NonInteractive -NoLogo -WindowStyle Hidden -ExecutionPolicy Unrestricted -File \"" + winrt::to_string(installationFolder) + "\\WinUI3Apps\\Assets\\Settings\\Scripts\\DisableModule.ps1" + "\"";
622+
#endif
623+
614624

615625
system(command.c_str());
616626

0 commit comments

Comments
 (0)