Code: Select all
ReStartExplorer( WaitSecs = 10 ) { ; SKAN, CD:07-Dec-2013 LM:14-Dec-2014 | goo.gl/UnS2rl
; Credit: Gracefully Exit Explorer (Programmatically) - Stack Overflow | goo.gl/tAA9HY
; Thanks to chaz - http://ahkscript.org/boards/viewtopic.php?p=7099#p7099
If A_OSVersion not in WIN_XP,WIN_VISTA,WIN_7
Return 0, ErrorLevel := 1
If ( A_OSVersion = "WIN_XP" ) {
WinGet, ShellPID, PID, ahk_class Progman
PostMessage, 0x012, 0, 0,, ahk_class Progman ; WM_QUIT = 0x12
} Else {
WinGet, ShellPID, PID, ahk_class Shell_TrayWnd
PostMessage, 0x5B4, 0, 0,, ahk_class Shell_TrayWnd ; WM_USER + 0x1B4
}
Process, WaitClose, %ShellPID%, %WaitSecs%
IfEqual, ErrorLevel, 0, Run %A_WinDir%\explorer.exe
Return !ErrorLevel
}