I'm currently using this code to restore a minimized window, and it works perfectly when I try to restore a window that runs under my own user account.
ShowWindow(wHandle, SW_RESTORE);
The problem arises when I try to restore a window that runs under the SYSTEM account. I found out that ShowWindow() always returns a false value to me. Also, in my manifest, I have tried setting it to both "Requires Administrator" and "As Invoker", but it still yields the same result.
Is there another function that works similarly to ShowWindow() and is able to restore a window that is running under the SYSTEM account?
You can create a thread with "local system" privileges in the user application. Then execute your
ShowWindowin the thread.Some steps:
OpenProcessTokenandDuplicateTokenExto create a Local System tokenSetTokenInformationto change the token session ID to match the program'sDuplicateHandleto create handle to the tokenSetThreadTokenusing the received handleRefer: Run process as Local System
For the @fpiette's comment, Interacting with a User from a Service Indirectly shows more details.