I've been troubleshooting my machine hanging intermediately after windows starts shutting down and I know that the source of the problem can be quite hard to determine. But before someone attempts to assit me with troubleshooting my machine or pointing to other forums remember thats not what I asked.
Shutdown(12) Forces Windows to shutdown
Question:
How to force the machine to power down A.K.A holding down the power button.
I've written a little script using some snippets I found on the forums to help those troubleshooting their own machines:
--Shutdown Assistant--
It can be used to determine if a non system service process is causing the hang up.
*Edit I realize that this probably won't work if something such as AV is causing the issue
Shutdown(12) Forces Windows to shutdown
Question:
How to force the machine to power down A.K.A holding down the power button.
I've written a little script using some snippets I found on the forums to help those troubleshooting their own machines:
--Shutdown Assistant--
[ autoit ]
#NoTrayIcon #include <Misc.au3> If _Singleton("ShutdownAssitant", 1) = 0 Then Exit $WM_QUERYENDSESSION = 0x11 Local $sSystem = "[System Process],System,smss.exe,csrss.exe,winlogon.exe,services.exe,lsass.exe,svchost.exe,explorer.exe,uphclean.exe,wmiprvse.exe" Local $aSystem = StringSplit($sSystem,",", 1) GUIRegisterMsg($WM_QUERYENDSESSION, "ForceShutdown") GUICreate("Shutdown Assistant") GUISetState(@SW_HIDE) ; set highest notification level If Not _SetProcessShutdownParameters(0xFFF) Then ; MSDN says maximum is 0x4FF, but it worked for me If Not _SetProcessShutdownParameters(0x4FF) Then ; MSDN says this is reserved for System, but worked for me _SetProcessShutdownParameters(0x3FF) ; highest not reserved number, if everything else does not work EndIf EndIf Global $b_ShutdownInitiated = False While ($b_ShutdownInitiated == False) sleep(10) WEnd Func TerminateSession() Local $list = ProcessList() For $i = 1 To $list[0][0] if Not IsSystem($list[$i][0], $list[$i][1]) Then ProcessClose($list[$i][0]) Next EndFunc Func IsSystem($sProcess, $iPID) For $i = 1 To $aSystem[0] Step 1 If $sProcess == $aSystem[$i] Or $iPID == @AutoItPID Then Return True Next EndFunc Func ForceShutdown($hWndGUI, $MsgID, $WParam, $LParam) $b_ShutdownInitiated = True TerminateSession() Return True EndFunc Func _SetProcessShutdownParameters($dwLevel, $dwFlags=0) ; http://msdn.microsoft.com/en-us/library/ms686227%28VS.85%29.aspx ; Prog@ndy Local $aResult = DllCall("Kernel32.dll", "int", "SetProcessShutdownParameters", "dword", $dwLevel, "dword", $dwFlags) If @error Then Return SetError(1,0,0) Return $aResult[0] EndFunc
It can be used to determine if a non system service process is causing the hang up.
*Edit I realize that this probably won't work if something such as AV is causing the issue
![;)](http://aut1.autoit-cdn.com/forum/public/style_emoticons/default/wink.png)