Jump to content
Sign in to follow this  
mozart90

How to detect a File is used by another User ?

Recommended Posts

mozart90

Hi

is there a possibility to detect whether a file is already in use by another user?

geetings mozart90

Share this post


Link to post
Share on other sites
Joon

You can pipe out the NET FILE and parse it.

Share this post


Link to post
Share on other sites
seandisanti

You can pipe out the NET FILE and parse it.

if it's a file that is locked when in use by another user, then it should generate an @error if you try to FileOpen() it.

Share this post


Link to post
Share on other sites
mozart90

You can pipe out the NET FILE and parse it.

Sorry I don't understand. What Net File do you mean?

Can you explain please?

Greetings Mozart90

Share this post


Link to post
Share on other sites
dabus

Try this one :o

Dim $Result, $output=''
$Result=Run(@ComSpec &' /c net file', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
While 1
    $line = StdoutRead($Result)
    If @error = -1 Then ExitLoop
    $output = $output & @CR & $line
Wend
While 1
    $line = StderrRead($Result)
    If @error = -1 Then ExitLoop
    $output = $output & @CR & $line
Wend
MsgBox (0, 'Net file' , $ouput )

Share this post


Link to post
Share on other sites
mikeytown2

Info on net file

http://www.microsoft.com/resources/documen...s/net_file.mspx

Did some debuging on the code above use this

#include <Constants.au3>
Local $Result, $output=''
$Result=Run(@ComSpec &' /c net file', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
While 1
    $line = StdoutRead($Result)
    If @error = -1 Then ExitLoop
    $output = $output & @CR & $line
Wend
While 1
    $line = StderrRead($Result)
    If @error = -1 Then ExitLoop
    $output = $output & @CR & $line
Wend
MsgBox (0, 'Net file' , $output )
Edited by mikeytown2

Share this post


Link to post
Share on other sites
dabus

Arrg, include again.

Stupid me... :o

Edited by dabus

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×