Solved

Why doesn't ExitWindowsEx work when not logged in?

Posted on 1997-03-18
2
258 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
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now