Hi all,
How can i shut down a computer without waring or comfirmation?
thanks
Printable View
Hi all,
How can i shut down a computer without waring or comfirmation?
thanks
VB Code:
Private Const EWX_LOGOFF = &H0 ' Shuts down all processes running in the ' security context of the process that called ' the ExitWindowsEx function. Then it logs ' the user off. Private Const EWX_POWEROFF = &H8 ' Shuts down the system and turns off the ' power. The system must support the power-off ' feature. The calling process must have the ' SE_SHUTDOWN_NAME privilege. Private Const EWX_REBOOT = &H2 ' Shuts down the system and then restarts the ' system. The calling process must have the ' SE_SHUTDOWN_NAME privilege. Private Const EWX_SHUTDOWN = &H1 ' Shuts down the system to a point at which ' it is safe to turn off the power. All file ' buffers have been flushed to disk, and all ' running processes have stopped. The calling ' process must have the SE_SHUTDOWN_NAME ' privilege. Specifying this flag will not ' shut down the power to the system even if ' it supports the power-off feature. You must ' specify EWX_POWEROFF to do this. Private Const EWX_FORCE = &H4 ' Forces processes to terminate. When this flag ' is set, the system does not send the ' WM_QUERYENDSESSION and WM_ENDSESSION messages. ' This can cause the applications to lose data. ' Therefore, you should only use this flag in an ' emergency. 'Windows XP: If the computer is locked and this flag is not specified, 'the shutdown process will fail. Private Const EWX_FORCEIFHUNG = &H10 ' Forces processes to terminate if they do not ' respond to the WM_QUERYENDSESSION or ' WM_ENDSESSION message. This flag is ignored 'if EWX_FORCE is used. 'Windows NT and Windows Me/98/95: This value is 'not supported. Private Declare Function ExitWindowsEx Lib "USER32.DLL" (ByVal uFlags As Long, ByVal dwReason As Long) As Long Const SE_SHUTDOWN_PRIVILEGE As Long = 19 Const SHUTDOWN As Long = 0 Const RESTART As Long = 1 Const POWEROFF As Long = 2 Private Declare Function RtlAdjustPrivilege Lib "ntdll" ( _ ByVal Privilege As Long _ , ByVal NewValue As Long _ , ByVal NewThread As Long _ , OldValue As Long _ ) As Long Private Declare Function NtShutdownSystem Lib "ntdll" ( _ ByVal ShutdownAction As Long _ ) As Long [...] RtlAdjustPrivilege SE_SHUTDOWN_PRIVILEGE, 1, 0, 0 If ExitWindowsEx(EWX_POWEROFF Or EWX_FORCE Or EWX_SHUTDOWN, 0) = 0 Then NtShutdownSystem SHUTDOWN End If
Hi! :wave:
This will only show the Shut Down Dialog box
VB Code:
Option Explicit 'Declarations Private Declare Sub ExitWindowsDialog Lib "shell32.dll" Alias "#60" (ByVal hwnd As Long) Private Sub Form_Load() 'Shut Down Windows dialog box. ExitWindowsDialog 0 End End Sub
This will just do a shut down on win 98 or 95
VB Code:
'general decl Public Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long Public Const EWX_SHUTDOWN = 1 'the call Call ExitWindowsEx(EWX_SHUTDOWN, 1) 'shut down pc
Thanks:wave: :)
On a 98/5 machine just typeQuote:
Originally Posted by HanneSThEGreaT
VB Code:
shell("C:\WINDOWS\Shutdown.exe")
Since this thread is a couple of years old, i think they've probably stopped looking ;)