Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 273
  • Last Modified:

Why doesn't ExitWindowsEx work when not logged in?

I am writing a program that finishes by rebooting NT.  It is downloaded and run in a "service" context which means the system has no one logged on.  When I execute ExitWindowsEx(), it returns TRUE like its OK, but nothing happens.

Any wisdom here?
0
mikegar031697
Asked:
mikegar031697
1 Solution
 
sperlingCommented:
Services are not notified of shutdown until some undefined time after ExitWindowsEx returns. The problem might be that a service (yours?) somehow prevents the shutdown from completing.

What state is your service in? What parameters do you give to ExitWindowsEx? What control codes do you handle? What do you do after calling ExitWindowsEx? Are you certain noone's logged on?

Regards,

Erik.
0
 
eteCommented:
Services are notified of system shutdown after a specified time, which defaults to 20 sec. If you call ExitWindowsEx() from your service, you can first register a Control Console Handler to watch the logoff and shutdown events. These handlers originate to console applications, but in Win32 they are available to any type of applications. However, this only a way to catch the shutdown event.

Like Erik noted, is your service accepting required control codes?

If your service calls another executable, that performs the system shutdown, you have to ensure, that the child process has adequite privilegies. All processes are run under "account". Typically the services are run under SYSTEM account and it's access rights and privilegies are inherited by the child processes. You have to note, that not all the SYSTEM privilegies are necessarily activated.  Use AdjustTokenPrivileges() API call to enable shutdown privilege.

Best regards
ETE

0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now