how to get the full path of an open file
Solution 1:
I have found the following useful:
openfiles /query /v | findstr "string what You want"
Solution 2:
You should use PsFile
About it
The "net file" command shows you a list of the files that other computers have opened on the system upon which you execute the command, however it truncates long path names and doesn't let you see that information for remote systems. PsFile is a command-line utility that shows a list of files on a system that are opened remotely, and it also allows you to close opened files either by name or by a file identifier.
Solution 3:
Ah ... looks like I had actually found this a year or more ago.
Turns out that if you give net file
the ID of an open file, it will output the full path.
So for my example in the question, if I typed
C:\>net file 2
I would get
File ID 2
User name huttarl
Locks 0
Path C:\Program Files\Apache Software Foundation\cocoon-2.1.11\
Permissions (none)
The command completed successfully.
Using this feature would mean
- parsing out the ID numbers from the output of the initial
net file
command - looping through them and calling
net file
again with each ID - testing the second output
- and closing the files whose paths match the pattern.
Whereas with PSFile, I could do all this with one simple command. But with net use
, I don't have to install 3rd-party software when we migrate the script to a new server. Decisions, decisions...