In the Inno Setup script I'm currently writing, I need to run a PowerShell command to restore a previously installed Windows extension, while the uninstaller is executed. This command need to run on the original user side, because otherwise the extension will be installed on the wrong account (the admin one, as the uninstaller is run as admin).
During the installation, I can use the ExecAsOriginalUser() function to achieve a such task. Unfortunately this function is not allowed at the uninstall time (see https://jrsoftware.org/ishelp/index.php?topic=isxfunc_execasoriginaluser remarks)
The PowerShell command I need to execute is the following:
winget install -e -h --id=9PMMSR1CGPWG --source=msstore --accept-package-agreements --accept-source-agreements --disable-interactivity
And here is the code I want ideally to run on uninstall time (but not working, as said above):
Result := ExecAsOriginalUser('powershell.exe', 'winget install -e -h --id=9PMMSR1CGPWG --source=msstore --accept-package-agreements --accept-source-agreements --disable-interactivity', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
However, as I cannot use ExecAsOriginalUser() on uninstall time, what is the correct way to execute a such command in these conditions?