Page 1 of 1

List of all dirs in Windows Explorer that are open (or "active"?)

Posted: 2021-Jul-24, 10:52 pm
by MigrationUser
15 Mar 2020 17:01
Marceepoo


I want to create a vbscript that would create a text file list of all the directories in Windows Explorer that are open (or is "active" a better term than "open"?) when I run the script.
It does not absolutely have to be a vbscript. It could be a DOS command or batch file, or a Python script.
During my work day, I have Windows Explorer open in 5 to 15 or even 20 directories, which I am keeping open in Windows Explorer to look for info about files, while I am working.
I need the list of those directories, so that when I resume work after rebooting, I will be able to remember to resume searching for relevant files in those directories.
I am unable to remember the list of directories that were open (which I was keeping open to look for info), and I need a programmatic way to save the list.
I have searched for many hours trying to find a way to get a list of those directories programmatically.
I looked at the Nirsoft suite, but could not figure out how to extract that info from the programs in that suite. (I tried; I apologize for not being smart enough, and for importuning upon your valuable time.)
Any help would be much appreciated.

Thanks,

Marc

----------------------------

#2 14 Apr 2020 15:28
Hackoo


Hi wink
You can give a try for this vbscript : Listing_All_Opened_Folders.vbs

Code: Select all

Option Explicit
Dim FilePath,TaskName,Repeat_Task
FilePath = WScript.ScriptFullName
TaskName = "Opened_Folders"
Repeat_Task = 60
Call Create_Schedule_Task(Repeat_Task,TaskName,FilePath)
Call WriteLog(Get_Date_Time & vbCrlf & String(100,"-") & vbcrlf & Opened_Folders & String(100,"-"))
'--------------------------------------------------------------------------------------------------
Function Opened_Folders()
	Dim objShellApp,wFolder,Open_Folder,F
	Set objShellApp = CreateObject("Shell.Application")
	For Each wFolder In objShellApp.Windows
		Open_Folder = wFolder.document.Folder.Self.Path
		F = F & Open_Folder & vbcrlf
	Next
	Opened_Folders = F
End Function
'--------------------------------------------------------------------------------------------------
Sub WriteLog(strText)
	Const ForAppending = 8
	Dim fs,ts, LogFile 
	LogFile = Left(Wscript.ScriptFullName,InstrRev(Wscript.ScriptFullName, ".")) & "txt"
	Set fs = CreateObject("Scripting.FileSystemObject")
	Set ts = fs.OpenTextFile(LogFile,ForAppending,True)
	ts.WriteLine strText
	ts.Close
End Sub
'---------------------------------------------------------------------------------------------------
Function Get_Date_Time()
	Get_Date_Time = LPad(Day(Now),2,"0") & "/" & LPad(Month(Now),2,"0") & "/" & Year(Now) &_
	vbTab & LPad(Hour(Now),2,"0") & ":" & LPad(Minute(Now),2,"0")  & ":" & LPad(Second(Now),2,"0")
End Function
'---------------------------------------------------------------------------------------------------
Function LPad(s, l, c)
	Dim n : n = 0
	If l > Len(s) Then n = l - Len(s)
	LPad = String(n, c) & s
End Function
'---------------------------------------------------------------------------------------------------
Sub Create_Schedule_Task(Repeat_Task,TaskName,FilePath)
Dim Ws,Task,Result
Set Ws = CreateObject("Wscript.Shell")
Task = "CMD /C Schtasks /Create /SC DAILY /ST 08:00 /F /RI "&_
Repeat_Task &" /DU 24:00 /TN "& TaskName &" /TR "& FilePath &""
Result = Ws.run(Task,0,True)
End Sub
'---------------------------------------------------------------------------------------------------
Last edited by Hackoo (14 Apr 2020 17:19)

original thread: https://ss64.org/oldforum/viewtopic.php?id=2433