On 10/17/25 4:49 AM, 'Bernd Bührer' via innosetup wrote:
> So InnoSetup would have to request elevated-privileges when it starts and "
> PrivilegesRequired=admin" is set!
> But it doesn't.
There are typically 4 processes running:
1. setup.exe, non-elevated (Started by the user)
2. setup.tmp, non-elevated
3. setup.exe, elevated
4. setup.tmp, elevated
Process 1 starts 2, 2 starts 3, and 3 starts 4.
The actual installation (including the wizard UI) runs in process 4,
which is elevated.
When the installation completes and you click Finish, process 4 exits,
then process 3 exits, then process 2 exits, then process 1 initiates the
restart.
Since process 1 isn't elevated, the restart fails on Windows Server.
This seems to be a new-ish problem, as Windows Server used to ship with
UAC disabled by default.
I see two possible solutions:
(1) If process 1 doesn't possess the shutdown privilege, then instead of
calling ExitWindowsEx directly, it could run "shutdown.exe /r" with
elevation. This would however cause a UAC dialog to appear, saying:
Windows Shutdown and Annotation Tool
Publisher: Microsoft Windows
(2) Process 3 could initiate the restart. This avoids showing another
UAC dialog, but is a more invasive change, because the processes would
have to exit in a different order (2, 1, 4, 3) to ensure that the first
2 processes don't block the shutdown and that all temporary files are
cleaned up properly.
But solution 2 still wouldn't work when PrivilegesRequired=lowest
because in that case no processes are elevated. So "shutdown.exe /r"
would be needed there, or that case could just be unsupported, because
why would a per-user install need to restart the whole system?
I kind of like solution 1 more because the processes still exit in their
natural order (4, 3, 2, 1). The extra UAC dialog is a little annoying,
but do users really care?
Will keep looking into it...
-JR