I think the problem is similar to this thread: ExitWindowsEx fails when Windows desktop Locked.
And according to the MSDN: The function is designed to stop all processes in the caller's logon session. Therefore, if you are not the interactive user, the function can succeed without actually shutting down the computer. If you are not the interactive user, use the InitiateSystemShutdown
or InitiateSystemShutdownEx
function.
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.