Solved

Shut down, restart and logoff?

Posted on 2000-04-16
11
358 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
TVirtualStringTree  search using TEdit 7 121
Convert Jpg /PNG To GIF 5 135
Delphi - replicating a form 8 74
select query - oracle 16 100
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…
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 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