Solved

Shut down, restart and logoff?

Posted on 2000-04-16
11
362 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
Independent Software Vendors: 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!

 

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 40 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

728 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