?
Solved

restart

Posted on 1997-02-20
1
Medium Priority
?
190 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 400 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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses
Course of the Month11 days, 3 hours left to enroll

770 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