Windows NT does not allow ExitWindows & ExitWindowsEx
The above tip won't work - because you're running Windows NT. Windows NT, as a security measure, demands that programs explicitly request access to shut down the machine - if this is not done, the kernel silently ignores the shutdown request. I'm not going to go into the necessary AdjustTokenPrivileges calls; there are dozens of examples in the forum, just use the search feature.
ExitWindowsEx API function
Just Paste this into your code & it should work.
Code:
Option Explicit
Const EWX_LOGOFF = 0
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT = 2
Const EWX_FORCE = 4
Public Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Private Sub Form_Load()
Dim ret&
'Log Off the current user.
ret& = ExitWindowsEx(EWX_FORCE Or EWX_LOGOFF, 0)
'Shutdown the current windows
ret& = ExitWindowsEx(EWX_FORCE Or EWX_SHUTDOWN, 0)
'Reboot the windows
ret& = ExitWindowsEx(EWX_FORCE Or EWX_REBOOT, 0)
'Don't what this does? May be you can find it out...
ret& = ExitWindowsEx(EWX_FORCE Or EWX_FORCE, 0)
End Sub
:)