Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Shut down, restart and logoff?

Posted on 2000-04-16
11
Medium Priority
?
370 Views
Last Modified: 2010-04-04
How to shut down, restart and logoff a computer?
The codes should be able to FORCE all programs to close WITHOUT user's interventions, eg. ask the user to save, confirm exit, etc.
In addition, please tell me if the codes provided are compatible with NT.
Thanks.
0
Comment
Question by:yingkit
[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
  • 3
  • 3
  • 2
  • +2
11 Comments
 
LVL 7

Expert Comment

by:Motaz
ID: 2720083
Use ExitWindowsEx

see the help for more information about parameters which enables you to :

Enforce shutdown
Reboot
Logoff
and to see the difference between Windows versions

Motaz
0
 

Author Comment

by:yingkit
ID: 2720091
I have tried:
ExitWindowsEx(EWX_FORCE and EWX_SHUTDOWN,0);
ExitWindowsEx(EWX_FORCE and EWX_LOGOFF,0);
ExitWindowsEx(EWX_FORCE and EWX_REBOOT,0);
However, they cannot force all programs to close, eg. an unsaved text file in Notepad, it asks me to confirm saving.
0
 
LVL 7

Expert Comment

by:Motaz
ID: 2720100
When you click cancel save, did the computer resume to shutdown or it stopped shutdown?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:yingkit
ID: 2720104
It stopped shutdown and Notepad remained here.
0
 

Expert Comment

by:MaximW
ID: 2720142
In order to reboot the system in Win NT you need to adjust the process privileges before calling ExitWindowsEx
0
 

Expert Comment

by:niknoxe
ID: 2720144
Hi,

I'm struggling with this under NT, is is not working correct under NT. You use it with 98?

You must have the correct rights to shutdown a program (at least under NT). In the KB there is one example on how to impersonate..

If you need more, tell me.

CU
0
 

Expert Comment

by:MaximW
ID: 2720180
I used it with Win NT(workst,serv),2000
it works. Would you like a sample?
0
 

Author Comment

by:yingkit
ID: 2720198
This question has a deletion request Pending
0
 

Expert Comment

by:niknoxe
ID: 2720351
This question no longer is pending deletion
0
 

Expert Comment

by:niknoxe
ID: 2720352
Yes, please niknoxe@hotmail.com
0
 

Accepted Solution

by:
Grayl1 earned 160 total points
ID: 2720852
Hi!

Use “ExitWindowsEx(EWX_FORCE + EWX_SHUTDOWN, 0);” or “ExitWindowsEx(EWX_FORCE + EWX_REBOOT, 0);” or “ExitWindowsEx(EWX_FORCE + EWX_LOGOFF, 0);” to force ALL apps to close and then shutdown/reboot/logoff your computer. Nothing can stop it. It is so powerful that if you use Active Desktop in Win 98 as “view as webpage” then you will have to click the “Restore Active Desktop” link on your desktop next time you start your computer.

Good luck!
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

610 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