Solved

Shut down, restart and logoff?

Posted on 2000-04-16
11
356 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
  • 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Convert Jpg /PNG To GIF 5 117
Best Firemonkey component pack 1 85
Delphi: how to implement a User Shortcut mapper? 1 93
How to renew a Delphi rad-studio licence? 5 49
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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

932 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now