Jump to content
Sign in to follow this  
dr3amer

Restarting explorer but capable to reopen any previously open explorer windows

Recommended Posts

dr3amer

Hi guys,

I'm using this script to restart explorer.exe

#include <WinAPI.au3>
#include <WinAPISys.au3>

;Save icon positions (probably not needed since we are doing a graceful exit ..)
DllCall("shell32.dll", "none", "SHChangeNotify", "long", 0x8000000, "uint", BitOR(0x0, 0x1000), "ptr", 0, "ptr", 0)

;Close the explorer shell gracefully
$hSysTray_Handle = _WinAPI_FindWindow('Shell_TrayWnd', '')
_SendMessage($hSysTray_Handle, 0x5B4, 0, 0)

While WinExists($hSysTray_Handle)
    Sleep(500)
WEnd

_start_explorer()

While Not _WinAPI_GetShellWindow()
    Sleep(500)
WEnd

EnvUpdate()

; continue script

Exit

Func _start_explorer()
    $strComputer = "localhost"
    $objWMI = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
    Local $objexplorer = $objWMI.Get("win32_process")
    $objexplorer.create("explorer.exe")
EndFunc   ;==>_start_explorer

thanks to user Deye

Is there a way to recover whatever previously open explorer window?

Thanks!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.