Results 1 to 6 of 6

Thread: Shutdown without waring

  1. #1

    Thread Starter
    Hyperactive Member naruponk's Avatar
    Join Date
    Feb 2004
    Location
    Some where in the world
    Posts
    423

    Exclamation Shutdown without waring

    Hi all,

    How can i shut down a computer without waring or comfirmation?

    thanks

  2. #2
    Addicted Member Cimperiali's Avatar
    Join Date
    Oct 2002
    Location
    Milan, Italy, Europe
    Posts
    188

    For win 2000 and win Xp

    VB Code:
    1. Private Const EWX_LOGOFF = &H0       ' Shuts down all processes running in the
    2.                                      ' security context of the process that called
    3.                                      ' the ExitWindowsEx function. Then it logs
    4.                                      ' the user off.
    5. Private Const EWX_POWEROFF = &H8     ' Shuts down the system and turns off the
    6.                                      ' power. The system must support the power-off
    7.                                      ' feature. The calling process must have the
    8.                                      ' SE_SHUTDOWN_NAME privilege.
    9. Private Const EWX_REBOOT = &H2       ' Shuts down the system and then restarts the
    10.                                      ' system. The calling process must have the
    11.                                      ' SE_SHUTDOWN_NAME privilege.
    12. Private Const EWX_SHUTDOWN = &H1     ' Shuts down the system to a point at which
    13.                                      ' it is safe to turn off the power. All file
    14.                                      ' buffers have been flushed to disk, and all
    15.                                      ' running processes have stopped. The calling
    16.                                      ' process must have the SE_SHUTDOWN_NAME
    17.                                      ' privilege. Specifying this flag will not
    18.                                      ' shut down the power to the system even if
    19.                                      ' it supports the power-off feature. You must
    20.                                      ' specify EWX_POWEROFF to do this.
    21. Private Const EWX_FORCE = &H4        ' Forces processes to terminate. When this flag
    22.                                      ' is set, the system does not send the
    23.                                      ' WM_QUERYENDSESSION and WM_ENDSESSION messages.
    24.                                      ' This can cause the applications to lose data.
    25.                                      ' Therefore, you should only use this flag in an
    26.                                      ' emergency.
    27. 'Windows XP: If the computer is locked and this flag is not specified,
    28. 'the shutdown process will fail.
    29. Private Const EWX_FORCEIFHUNG = &H10 ' Forces processes to terminate if they do not
    30.                                      ' respond to the WM_QUERYENDSESSION or
    31.                                      ' WM_ENDSESSION message. This flag is ignored
    32.                                      'if EWX_FORCE is used.
    33.                                      'Windows NT and Windows Me/98/95:  This value is
    34.                                      'not supported.
    35.  
    36. Private Declare Function ExitWindowsEx Lib "USER32.DLL" (ByVal uFlags As Long, ByVal dwReason As Long) As Long
    37. Const SE_SHUTDOWN_PRIVILEGE As Long = 19
    38. Const SHUTDOWN As Long = 0
    39. Const RESTART As Long = 1
    40. Const POWEROFF As Long = 2
    41. Private Declare Function RtlAdjustPrivilege Lib "ntdll" ( _
    42.                   ByVal Privilege As Long _
    43.                 , ByVal NewValue As Long _
    44.                 , ByVal NewThread As Long _
    45.                 , OldValue As Long _
    46.                 ) As Long
    47.                
    48. Private Declare Function NtShutdownSystem Lib "ntdll" ( _
    49.                 ByVal ShutdownAction As Long _
    50.                 ) As Long
    51. [...]
    52. RtlAdjustPrivilege SE_SHUTDOWN_PRIVILEGE, 1, 0, 0
    53.     If ExitWindowsEx(EWX_POWEROFF Or EWX_FORCE Or EWX_SHUTDOWN, 0) = 0 Then
    54.         NtShutdownSystem SHUTDOWN
    55.    End If
    Special thanks to some wonderful people,
    such as Lothar the Great Haensler, Aaron Young,
    dr_Michael, Chris Eastwood, TheOnlyOne ClearCode....

  3. #3
    Frenzied Member HanneSThEGreaT's Avatar
    Join Date
    Nov 2003
    Location
    Vereeniging, South Africa
    Posts
    1,492
    Hi!

    This will only show the Shut Down Dialog box

    VB Code:
    1. Option Explicit
    2. 'Declarations
    3. Private Declare Sub ExitWindowsDialog Lib "shell32.dll" Alias "#60" (ByVal hwnd As Long)
    4.  
    5. Private Sub Form_Load()
    6. 'Shut Down Windows dialog box.
    7. ExitWindowsDialog 0
    8. End
    9.  
    10. End Sub

    This will just do a shut down on win 98 or 95
    VB Code:
    1. 'general decl
    2. Public Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
    3. Public Const EWX_SHUTDOWN = 1
    4.  
    5. 'the call
    6.     Call ExitWindowsEx(EWX_SHUTDOWN, 1) 'shut down pc
    Last edited by HanneSThEGreaT; May 21st, 2004 at 03:47 AM.
    VB.NET MVP 2008 - Present

  4. #4

    Thread Starter
    Hyperactive Member naruponk's Avatar
    Join Date
    Feb 2004
    Location
    Some where in the world
    Posts
    423
    Thanks

  5. #5
    Fanatic Member ididntdoit's Avatar
    Join Date
    Apr 2006
    Location
    :uoıʇɐɔoן
    Posts
    765

    Re: Shutdown without waring

    Quote Originally Posted by HanneSThEGreaT
    Hi!

    This will just do a shut down on win 98 or 95
    VB Code:
    1. 'general decl
    2. Public Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
    3. Public Const EWX_SHUTDOWN = 1
    4.  
    5. 'the call
    6.     Call ExitWindowsEx(EWX_SHUTDOWN, 1) 'shut down pc
    On a 98/5 machine just type
    VB Code:
    1. shell("C:\WINDOWS\Shutdown.exe")
    Visit here to learn to make the VB interface fit you!.
    "I have not failed 10,000 times. I have successfully identified 10,000 ways that will not work" Thomas Edison
    "The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners" -- Ernst Jan Plugge

  6. #6
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Shutdown without waring

    Since this thread is a couple of years old, i think they've probably stopped looking

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width