Results 1 to 3 of 3

Thread: How To Turn Computer Off Using VB??

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2005
    Location
    g33kland
    Posts
    1

    Question How To Turn Computer Off Using VB??

    Hi there.

    i was wondering if anyone knew how to turn a computer off using Visual Basic. Like a Subroutine what turns the computer off when referred to.

  2. #2
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: How To Turn Computer Off Using VB??

    VB Code:
    1. Private Declare Function ExitWindowsEx Lib "User32" ( _
    2.  ByVal dwOptions As Long, _
    3.  ByVal dwReserved As Long) As Long
    4.  
    5. Private Const EWX_SHUTDOWN = 1
    6. Private Const EWX_FORCE = 4
    7.  
    8. Public Sub ShutDown(Optional blnForce As Boolean)
    9.     Dim nFlags As Long
    10.  
    11.     nFlags = EWX_SHUTDOWN + IIf(blnForce, EWX_FORCE, 0)
    12.     Call ExitWindowsEx(nFlags, 0&)
    13. End Sub

  3. #3
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: How To Turn Computer Off Using VB??

    You could also use this command (on XP)

    VB Code:
    1. Shut down a server in a controlled manner.
    2.  
    3. TSSHUTDN [wait_time] [/SERVER:servername] [/REBOOT] [/POWERDOWN]
    4.          [/DELAY:logoffdelay] [/V]
    5.  
    6.   wait_time           Seconds to wait after user notification before
    7.                       terminating all user sessions (default is 60).
    8.   /SERVER:servername  The server to shut down (default is current).
    9.   /REBOOT             Reboot the server after user sessions are terminated.
    10.   /POWERDOWN          The server will prepare for powering off.
    11.   /DELAY:logoffdelay  Seconds to wait after logging off all connected
    12.                       sessions (default is 30).
    13.   /V                  Display information about actions being performed.

    You can shut of networked computers this way, also

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