# Visual Basic > Visual Basic 6 and Earlier >  VB6 QUESTION: Enumerate open Explorer windows and obtain Path

## yereverluvinuncleber

If you have several Explorer windows open, each to various distinct folders is it possible to extract the folder path of each?

I think I can successfully iterate through and identify explorer processes using APIs but I am unsure as to how to extract the currently selected path from each explorer instance - and whether that is even possible.

Assuming it is... Please enlighten me if you know how. I have done some digging on t'net but I cannot find the information that I expected to be close to hand for VB6.

----------


## Joe Caverly

I did a search on vbforums.com for


> explorer.exe


One of the results returned;

Get extended details about Explorer windows by getting their IFolderView

There are other results, which may also provide a solution for you.

Joe

----------


## yereverluvinuncleber

Thankyou Joe. I did look on't net but did not see that. I should have looked closer to home on VBforums. I will dig into that code and see what I can learn. It certainly seems to be able to extract the current path.

----------


## fafalone

You may be interested in a much simpler version of the same concept-- I made a "close Explorer window by path" function... Should be trivial to modify to keep the path list and not close them.

https://www.vbforums.com/showthread....window-by-path

----------


## yereverluvinuncleber

Thankyou both! That is a lot easier Faf. I will try to use your later code and see how it goes.

----------


## Joe Caverly

Here's another method to enumerate open Explorer windows, and obtain the path;

```
Option Explicit

Private Sub Form_Load()
  Dim oShell
  Dim oWindows
  Dim oExplorer
  Dim kount
  
  Set oShell = CreateObject("shell.Application")
  Set oWindows = oShell.Windows()
  
  Debug.Print CStr(oWindows.Count)
  
  For kount = 0 To oWindows.Count - 1
    Set oExplorer = oWindows.Item(kount)
    Debug.Print oExplorer.LocationURL
  Next
  Set oExplorer = Nothing
  Set oWindows = Nothing
  Set oShell = Nothing
  Unload Me
End Sub
```

Make sure to have at least one Explorer window open before you run this.

Here's the output after execution of the above code on my system;

```
2
file:///E:/Utils
file:///E:/Documents/vbscript/Shell.Windows
```

Joe



> Microsoft Visual Basic 6.0 (SP6)
> Windows 10 [Version 10.0.19044.2364]

----------


## yereverluvinuncleber

Thanks Joe, I am trying to avoid using the shell.Application due to a/v tools previously flagging resulting binary as possibly malicious. Interesting though.

----------

