CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2005
    Posts
    39

    Shutting dwn a win200 server pc

    I want to shut down a windows200 pc regularly at a fixed time regularly
    automatically.
    how can i made this by vb?
    can any batch file help me?

  2. #2
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Shutting dwn a win200 server pc

    You could try ExitWindowsEx API to do this..

    here is a sample from ALLAPI.NET
    Code:
    'In general section
    Const EWX_LOGOFF = 0
    Const EWX_SHUTDOWN = 1
    Const EWX_REBOOT = 2
    Const EWX_FORCE = 4
    Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
    Private Sub Form_Load()
    	'KPD-Team 1998
    	'URL: http://www.allapi.net/
    	'E-Mail: [email protected]
    	msg = MsgBox("This program is going to reboot your computer. Press OK to continue or Cancel to stop.", vbCritical + vbOKCancel + 256, App.Title)
    	If msg = vbCancel Then End
    	'reboot the computer
    	ret& = ExitWindowsEx(EWX_FORCE Or EWX_REBOOT, 0)
    End Sub

  3. #3
    Join Date
    May 2005
    Posts
    39

    Re: Shutting dwn a win200 server pc

    I tried it.
    but it doesn't work.
    is there any dos command to do so?

  4. #4
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Shutting dwn a win200 server pc

    Quote Originally Posted by opashafiq
    I tried it.
    but it doesn't work.
    is there any dos command to do so?
    I have a Windows 2000 PC with SP4.
    It works perfectly on my system.
    What exactly are you trying to do..

  5. #5
    Join Date
    Jul 2005
    Posts
    13

    Re: Shutting dwn a win200 server pc

    the command for shutdown on nt based systems under windows is-
    "shutdown -[option]"
    try out shell shutdown -l
    or
    shell "shutdown -l"

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

Featured