Results 1 to 5 of 5

Thread: [RESOLVED] pc shut down?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    Resolved [RESOLVED] pc shut down?

    are there commands in vb for turning my pc off after a 30 second timer?

    VB Code:
    1. Declare Function ExitWindowsEx Lib "user32" Alias "ExitWindowsEx" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long

    something to do with the abov but im not sure guys

  2. #2
    Fanatic Member
    Join Date
    Oct 2004
    Posts
    751

    Re: pc shut down?

    You can shell out to shutdown.exe

    Usage:
    shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "comment"] [-d up:xx:yy]

    No args Display this message (same as -?)
    -i Display GUI interface, must be the first option
    -l Log off (cannot be used with -m option)
    -s Shutdown the computer
    -r Shutdown and restart the computer
    -a Abort a system shutdown
    -m \\computername Remote computer to shutdown/restart/abort
    -t xx Set timeout for shutdown to xx seconds
    -c "comment" Shutdown comment (maximum of 127 characters)
    -f Forces running applications to close without war
    ning
    -d [u][p]:xx:yy The reason code for the shutdown u is the user code p is a planned shutdown code
    xx is the major reason code (positive integer less than 256)
    yy is the minor reason code (positive integer less than 65536)
    so...
    shutdown.exe -f -s -t 30

    Edit:
    http://www.mentalis.org/apilist/ExitWindowsEx.shtml
    Last edited by k1ll3rdr4g0n; Dec 3rd, 2005 at 08:14 PM.
    My Projects: [ Instant Messagener Client/Server ] [ VBPictochat ]

    My Sites:
    [ Datanethost ]
    [ Helpdesk ]

    Remember if my post was helpful then Rate This Post.

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

    Re: pc shut down?

    For 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.

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

    Re: pc shut down?

    VB Code:
    1. Private Const EWX_LOGOFF = 0
    2. Private Const EWX_SHUTDOWN = 1
    3. Private Const EWX_REBOOT = 2
    4. Private Const EWX_FORCE = 4
    5.  
    6. Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
    7.  
    8. Private Sub Command1_Click()
    9.     ret& = ExitWindowsEx(EWX_FORCE Or EWX_SHUTDOWN, 0)
    10. End Sub

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    Re: pc shut down?

    you guys are wicked, thanks alot!!

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