Solved

restart

Posted on 1997-02-20
1
188 Views
Last Modified: 2010-04-10
How do I execute a reboot from within Windows NT V4, The standard ExitWindows(EW_REBOOT,0) Just logs you out, and takes you to the logon screen.
0
Comment
Question by:r-carver
[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
1 Comment
 

Accepted Solution

by:
rob_garner earned 200 total points
ID: 1162246
ExitWindowsEx can be used to shutdown the system. but he calling process must have the SE_SHUTDOWN_NAME privilege. See the following example from the SDK documentation:

The following example enables the SE_SHUTDOWN_NAME privilege and then shuts down the system.
 
HANDLE hToken;
TOKEN_PRIVILEGES tkp;
 
/* Get a token for this process. */
 
if (!OpenProcessToken(GetCurrentProcess(),
        TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
    error("OpenProcessToken");
 
/* Get the LUID for the shutdown privilege. */
 
LookupPrivilegeValue(NULL, TEXT("SE_SHUTDOWN_NAME"),
        &tkp.Privileges[0].Luid);
 
tkp.PrivilegeCount = 1;  /* one privilege to set    */
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
 
/* Get the shutdown privilege for this process. */
 
AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
        (PTOKEN_PRIVILEGES)NULL, 0);
 
/* Cannot test the return value of AdjustTokenPrivileges. */
 
if (GetLastError() != ERROR_SUCCESS)
    error("AdjustTokenPrivileges");
 
/* Shut down the system and force all applications to close. */
 
if (!ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCE, 0))
    error("ExitWindowsEx");

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

688 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