Windows File Path Example

  1. Java Windows File Path
  2. File Path Definition
  3. Example Of A File Path
Active2 years, 10 months ago

You might, for example, want to add ADB tools as a path variable. In this brief guide, we’ve talked about adding the path to an EXE however, you can add the path to other executable file types as well. For example, Windows supports running.com,.exe,.bat, and.cmd files from the command line. Steps to find file path: Step 1: Open File Explorer. Step 2: Navigate to any file you wish to find file path of. Step 3: Click on the icon shown in the image below. Step 4: Press Ctrl + C to copy the path to clipboard so that you can use it later on. You’ve now learned how to find file path. Easy, wasn’t it? Applying the current directory. For example, if the file path is D:sources, the current directory is C: Documents, and the last current directory on drive D: was D: sources, the result is D: sources sources. These 'drive relative' paths are a common source of program and script logic errors.

I have script that runs on a Windows server to perform operations on certain files. The script often fails because various users (even myself) have open file shares on the server that they've forgotten to close, so the folders are locked.

I've added code to check for open files with net file, and close them if they match certain patterns. The limitation there is that net file summarizes the path of the open files, e.g.

when the full path of the open file is

So when my script checks that the file path matches a certain pattern, such as 'Apache', it sometimes misses files that have ... in the middle of their net file listing.

So my question is, how can I get the full path of an open file, in a script?

Currently, I'm using cygwin/bash. So if I have to switch to WSH, there will be some porting to do. But if that's the only option, I'll go for it.

If it matters, the system information panel says my Windows edition is Windows Server Standard, (c) 2007, SP2.

LarsH
LarsHLarsH
2653 gold badges7 silver badges19 bronze badges

3 Answers

I have found the following useful:

openfiles /query /v | findstr 'string what You want'

user117001user117001

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.

PathRex
7,4523 gold badges23 silver badges43 bronze badges
cuonglmcuonglm
2,1232 gold badges12 silver badges20 bronze badges

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

I would get

Java Windows File Path

File

File Path Definition

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...

LarsH

Example Of A File Path

LarsH
2653 gold badges7 silver badges19 bronze badges

Not the answer you're looking for? Browse other questions tagged scriptingnetwork-sharewindows or ask your own question.