How to determine if file on another machine is being accessed

2

I would like to determine if a file on another computer (or network) is currently being accessed. Ideally, I want to perform this task in a batch file, but other methods of performing this feat is welcomed. Also, if there a way to be notified when the file is not being accessed (locked) anymore? Thanks.

Mark

Edit: Sorry, I failed to mention the OS. This is on Windows based machines and primarily Windows XP SP2/SP3 machines.

lordhog

Posted 2010-07-26T18:47:31.383

Reputation: 187

1This depends greatly on the OS you are using. – KeithB – 2010-07-26T19:30:16.870

Answers

0

Not sure if this meets your needs.

http://www.thecodeline.com/ShareWatcher.aspx

.

Moab

Posted 2010-07-26T18:47:31.383

Reputation: 54 203

Not exactly. Basically, I have a tester that is creating log files which a server collects during the day. There are times when the server is copying over the files though one may be currently locked. My IT person is looking for a way to determine if the test program still has a lock (or has the file open for writing). Ideally, I don't want to use any third party utilities if I can help it as my IT person doesn't want to install anything on the server. – lordhog – 2010-07-26T22:45:19.160

Going to be hard to do without software, at least for me, here is a utility from microsoft that may reveal what process or program has a file locked. http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx

– Moab – 2010-07-27T14:03:56.710

I was looking at "PsExec" and "Handle" to attempt this feat. If running the "Handle" program locally the program will show which process has a handle of the input criteria. I then tried executing "Handle" remotely by using the following snytax:

psexec \10.0.0.1 -u "doman\user" -p "password" -c handle.exe "FileToCheck.ext"

Which executed the program, but the only problem is that "PsExec" only returns the exit code. I had not figured out how to retrieve any info if a handle was found. – lordhog – 2010-07-27T23:55:51.480