Solved

Why doesn't ExitWindowsEx work when not logged in?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Visual Studio Exe Issue, 12 27
Messagebox for a Web Site Application 4 63
Which Microsoft MSDN Package Is The One I need? 3 41
Poor Man's .NET Framework Certification 2 47
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
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…

920 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

16 Experts available now in Live!

Get 1:1 Help Now