When we have to restart explorer.exe
, usually we have many folders opened, which get closed in the process. There is a way to re-open these folders automatically after restarting explorer using bat script:
@echo off
setlocal enabledelayedexpansion
powershell @^(^(New-Object -com shell.application^).Windows^(^)^).Document.Folder.Self.Path >> openedpaths.txt
taskkill /im explorer.exe /f
start explorer.exe
FOR /F "tokens=*" %%f IN (%~dp0openedpaths.txt) DO (
set "var=%%f"
set "firstletters=!var:~0,2!"
IF "!firstletters!" == "::" ( start /min shell:%%~f ) ELSE ( start /min "" "%%~f" )
)
del "%~dp0openedpaths.txt"
Save script above with .bat extension and it ready to work.
Ref: https://superuser.com/a/1700084/1698376
Nam Le
Nam Le
lequocnam
0 responds