Home All Groups Group Topic Archive Search About
Author
25 Mar 2009 1:37 PM
Shell
In windows XP Pro and VB6.  I have a VB6 executable that automatically runs
every day several hours after I leave work.  I want to add some code that
will shut down the computer at the end of the process.

How can I do this?

Thanks
--
Shell

Author
25 Mar 2009 1:43 PM
Daryl Muellenberg
' SHUT DOWN AND RESTART IN VB6
       Const EWX_LogOff As Long = 0
       Const EWX_SHUTDOWN As Long = 1
       Const EWX_REBOOT As Long = 2
       Const EWX_FORCE As Long = 4
       Private Declare Function ExitWindows _
               Lib "User32" Alias "ExitWindowsEx" _
               (ByVal dwOptions As Long, ByVal dwReserved As Long) As Long

     Private Sub Command1_Click()

          'Shut down windows
          ExitWindows EWX_SHUTDOWN, &HFFFFFFFF

     End Sub

     Private Sub Command2_Click()

          'Reboot
          ExitWindows EWX_REBOOT, &HFFFFFFFF

     End Sub



Show quoteHide quote
"Shell" <Sh***@discussions.microsoft.com> wrote in message
news:997F47E2-0DA2-4E11-8DC5-F0A7C823BF2E@microsoft.com...
> In windows XP Pro and VB6.  I have a VB6 executable that automatically
> runs
> every day several hours after I leave work.  I want to add some code that
> will shut down the computer at the end of the process.
>
> How can I do this?
>
> Thanks
> --
> Shell
Author
25 Mar 2009 5:13 PM
MikeD
Show quote Hide quote
"Daryl Muellenberg" <dmuellenb***@comcast.net> wrote in message news:%23T4EdAVrJHA.5916@TK2MSFTNGP02.phx.gbl...
>' SHUT DOWN AND RESTART IN VB6
>       Const EWX_LogOff As Long = 0
>       Const EWX_SHUTDOWN As Long = 1
>       Const EWX_REBOOT As Long = 2
>       Const EWX_FORCE As Long = 4
>       Private Declare Function ExitWindows _
>               Lib "User32" Alias "ExitWindowsEx" _
>               (ByVal dwOptions As Long, ByVal dwReserved As Long) As Long
>
>     Private Sub Command1_Click()
>
>          'Shut down windows
>          ExitWindows EWX_SHUTDOWN, &HFFFFFFFF
>
>     End Sub
>
>     Private Sub Command2_Click()
>
>          'Reboot
>          ExitWindows EWX_REBOOT, &HFFFFFFFF
>
>     End Sub
>
>


That most likely will not work.  The app must have the shutdown privilege.

PRB: ExitWindowsEx API Does Not Reboot Windows NT
http://support.microsoft.com/kb/176695


--
Mike