Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 377
  • Last Modified:

Shut down, restart and logoff?

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
yingkit
Asked:
yingkit
  • 3
  • 3
  • 2
  • +2
1 Solution
 
MotazCommented:
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
 
yingkitAuthor Commented:
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
 
MotazCommented:
When you click cancel save, did the computer resume to shutdown or it stopped shutdown?
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
yingkitAuthor Commented:
It stopped shutdown and Notepad remained here.
0
 
MaximWCommented:
In order to reboot the system in Win NT you need to adjust the process privileges before calling ExitWindowsEx
0
 
niknoxeCommented:
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
 
MaximWCommented:
I used it with Win NT(workst,serv),2000
it works. Would you like a sample?
0
 
yingkitAuthor Commented:
This question has a deletion request Pending
0
 
niknoxeCommented:
This question no longer is pending deletion
0
 
niknoxeCommented:
Yes, please niknoxe@hotmail.com
0
 
Grayl1Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 3
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now