Private Declare Function InitiateSystemShutdown _
Lib "advapi32.dll" Alias "InitiateSystemShutdownA" _ (ByVal lpMachineName As String, _ ByVal lpMessage As String, ByVal dwTimeout As Integer, _ ByVal bForceAppsClosed As Long, _ ByVal bRebootAfterShutdown As Long) As Long Private Declare Function AbortSystemShutdown _ Lib "advapi32.dll" Alias "AbortSystemShutdownA" _ ByVal lpMachineName As String) As Long Public Function ShutDownComputer(CompName as String, _ MessageToUser as String, SecondsUntilShutdown as Long, _ ForceAppsClosed as Integer, RebootAfter as Integer) ShutDownComputer = InitiateSystemShutdown(CompName, _ MessageToUser, SecondsUntilShutdown, _ ForceAppsClosed, RebootAfter) End Function Public Function AbortShutdown(CompName as String) AbortShutdown = AbortSystemShutdown(ComName) End Function ' NOTES: ' + Shutdown can only be aborted while the countdown is going. ' + Both Functions return "0" when failed, "1" when Successful Inputs: Machine Name, Wait Until Shutdown, Force Apps Closed, Reboot After Shutdown, Message to display. Returns: 1 if Successful Assumes: This code may not work if you don't have Admin Privlages And users that you Do this could Get tee'd off at you If you don'tnotify them 1st... ;) Side Effects: If you specify an invalid machine name, the program hangs for a few seconds. (Depending On Wait Time) |