Solved

Why doesn't ExitWindowsEx work when not logged in?

Posted on 1997-03-18
2
267 Views
Last Modified: 2013-12-03
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
Comment
Question by:mikegar031697
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Expert Comment

by:sperling
ID: 1298566
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
 
LVL 1

Accepted Solution

by:
ete earned 100 total points
ID: 1298567
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question