2

After much research, I must ask:

  • Is there a way to obtain a list of folders—not files—and possibly their paths which are opened in Windows 7?

I'd like to get folders from the file system not application windows.

I tried SysInternal's ProcessExplorer to with no success. The closest I have gotten is taking a screenshot of the taskbar popup for Windows Explorer.

0

1 Answer 1

1

You could use the Handle application and then filter applicable results using the Find command to specify "files" for the object types like some of the below examples.

You can scale these methods even more to satisfy your needs by including and excluding certain string patterns to only show folder object types and exclude certain file extensions.


Syntax Examples

  1. The below will show only results containing the string " file " that include the leading and trailing space before and after the commas next to the characters "files"

    handle64 -a | FIND /I " file "


Narrowing it down more

You could additionally add more FIND command filters to narrow the results down even further by depending on your criteria and pipe each FIND command to the next FIND command to bring back included and excluded matched strings.

  • FIND /I "<string>": means to ignore case sensitivity of characters and show results only containing the specific matching string.
  • FIND /I /V "<string>": adding the /V switch exludes all lines containing the specific matching string.

  1. The below will show only results containing the string " file " (just as the above example) and then those results piped over to the next FIND command to then only show the remaining results containing the ":\" (colon and backslash) characters.

    handle64 -a | FIND /I " file " | FIND /I ":\"

  2. The below will show only results containing the string " file " and those results piped over to the next FIND command and those results then piped over to the next find command with the /V switch to exclude and not show results matching this pattern.

    handle64 -a | FIND /I " file " | FIND /I ":\" | FIND /I /V "C:\Windows"


Scaling and Other Tools

You could keep scaling applicable commands by piping one over to the next to do further exclusions, etc. such as excluding file extensions of ".bin", and so on until you get the desired results that meet the criteria you need.

You could probably use PowerShell and/or FINDSTR to do this more efficiently but I don't have time to do a bunch of testing right now so I thought I'd drop this quick method over to you which may suit your needs.


Handle

Introduction

Ever wondered which program has a particular file or directory open? Now you can find out. Handle is a utility that displays information about open handles for any process in the system. You can use it to see the programs that have a file open, or to see the object types and names of all the handles of a program.

You can also get a GUI-based version of this program, Process Explorer, here at Sysinternals.

Installation

You run Handle by typing "handle". You must have administrative privilege to run Handle.

Usage

Handle is targeted at searching for open file references, so if you do not specify any command-line parameters it will list the values of all the handles in the system that refer to open files and the names of the files. It also takes several parameters that modify this behavior.

usage: handle [[-a] [-u] | [-c <handle> [-l] [-y]] | [-s]] [-p <processname>|
<pid>> [name]

-a    Dump information about all types of handles, not just those that refer
      to files. Other types include ports, Registry keys, synchronization        
      primitives, threads, and processes.
-c    Closes the specified handle (interpreted as a hexadecimal number). You
      must specify the process by its PID.
      WARNING: Closing handles can cause application or system instability.
-l    Dump the sizes of pagefile-backed sections.
-y    Don't prompt for close handle confirmation.
-s    Print count of each type of handle open.
-u    Show the owning user name when searching for handles.
-p    Instead of examining all the handles in the system, this parameter
      narrows Handle's scan to those processes that begin with the name 
      process. Thus:

handle -p exp

      would dump the open files for all processes that start with "exp", 
      which would include Explorer.
name  This parameter is present so that you can direct Handle to search
      for references to an object with a particular name.

      For example, if you wanted to know which process (if any) has
      "c:\windows\system32" open you could type:

      handle windows\system

      The name match is case-insensitive and the fragment specified can be
      anywhere in the paths you are interested in.

Handle Output

When not in search mode (enabled by specifying a name fragment as a parameter), Handle divides its output into sections for each process it is printing handle information for. Dashed lines are used as a separator, immediately below which you will see the process name and its process id (PID). Beneath the process name are listed handle values (in hexadecimal), the type of object the handle is associated with, and the name of the object if it has one.

When in search mode, Handle prints the process names and id's are listed on the left side and the names of the objects that had a match are on the right.

Download Handle

source


Further Resources

2
  • This helps. I am toying with it. It still returns too much, but then too much is better than nothing. Your showing of the exclude switch was very helpful. "Handle" also gives me a listing of the PDFs I have open. This is nice, as "recent" is not the same as open. Thanks.
    – JayJay123
    Aug 10, 2016 at 5:00
  • Alright. Still not perfect, but much better than what I had--nothing. I have now come up with the following utilizing your answer: handle64 -p explorer | FIND /I "C:\Users\User" | FIND /I /V "AppData" I dropped the "-a" switch, and then narrowed things, down using the "-p" switch, to just those processes involving "Explorer." I then tossed all references to "AppData," as they were polluting the results. The Strange thing is that the result has folders listed that I do not have open. Probably some Windows thing. Anyways, thanks again.
    – JayJay123
    Aug 10, 2016 at 8:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .