?
Solved

Why doesn't ExitWindowsEx work when not logged in?

Posted on 1997-03-18
2
Medium Priority
?
269 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 300 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
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…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

765 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