Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

restart

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

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…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.
Suggested Courses

810 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