-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.bat
More file actions
31 lines (30 loc) · 1003 Bytes
/
Copy pathscript.bat
File metadata and controls
31 lines (30 loc) · 1003 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
powershell -File ".\script.ps1"
@echo off
Title Kill and restart Explorer.exe and restore all the windows by Hackoo 2020
Color 0A
Set "VBSFILE=%~dpn0.vbs"
> "%VBSFILE%" (
echo Wscript.Echo Opened_Folders
echo Function Opened_Folders
echo Dim objShellApp,wFolder,Open_Folder,F
echo Set objShellApp = CreateObject("Shell.Application"^)
echo For Each wFolder In objShellApp.Windows
echo Open_Folder = wFolder.document.Folder.Self.Path
echo F = F ^& Open_Folder ^& vbcrlf
echo Next
echo Opened_Folders = F
echo End Function
)
REM Populate the array with existent and opened folders
SetLocal EnableDelayedExpansion
Set /a Count=0
for /f "delims=" %%a in ('Cscript //NoLogo "%VBSFILE%"') do (
Set /a Count+=1
Set "Folder[!Count!]=%%a"
)
Taskkill /f /IM "explorer.exe"
Timeout /T 1 /NoBreak>nul
Start Explorer.exe
rem Restore all folders before killing explorer process
for /L %%i in (1,1,%Count%) do Explorer "!Folder[%%i]!"
exit