How to Execute API in Separate Process?

john weiss 21 Reputation points
2021-06-09T15:58:26.6+00:00

In VBA, i'm trying to execute ExitWindowsEx, and immediately quit my application.

it succeeds if i don't close Excel.

but, i want the ExitWindowsEx to continue executing after i quit my application.

Problem: When my application quits, ExitWindowsEx fails. it must be running within my application thread or process.

How to run ExitWindowsEx in a separate process?

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,429 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Song Zhu - MSFT 906 Reputation points
    2021-06-10T05:59:22.073+00:00

    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.