Jump to content

Recommended Posts

Posted

Hello,

i need to force closing of remotely opened file in specific path on my server, so i wanted to use the "net file" (standard Windows command)  or "psfile" (from Microsoft Pstools, better than "net file" because it doesn"t truncate the full path of opened file)  tool to list locked files and close them.

Here is what i already found to start :

$strCmdOutput = Run(@ComSpec & " /c C:\Temp\psfile.exe", "", Default, $STDERR_MERGED)
$strLockedFilesList = ""
While 1
    $strSTDOUT = StdoutRead($strCmdOutput)
    If $strSTDOUT <> "" Then $strLockedFilesList = $strLockedFilesList & @CRLF & $strSTDOUT
    If @error Then ExitLoop
WEnd
MsgBox (0, "List of Locked cifs files", $strLockedFilesList)

Autoit code actually shows me the window you'll see in the attached screenshot.

Command line output will generally give something like that :

C:\>C:\Temp\psfile.exe

psfile v1.02 - psfile
Copyright ® 2001 Mark Russinovich
Sysinternals

Files opened remotely on MYCOMPUTER:

[805307366] C:\Temp\efzefezfzefezfzefzefzef\erregregergregergerg\toto.pdf
    User:   ADMINISTRATEUR
    Locks:  0
    Access: Read
[805307371] C:\Temp
    User:   ADMINISTRATEUR
    Locks:  0
    Access: Read
[805307384] C:\Temp\titi.pdf
    User:   ADMINISTRATEUR
    Locks:  0
    Access: Read

What i need to do is to extract each lock numbers (numbers between the "[" and the "]") and run another command with them in parameter..

Thanks for your help

Florent

post-2780-0-60744300-1385719829_thumb.jp

Posted

try _StringBetween()

Signature - my forum contributions:

  Reveal hidden contents

 

  • 2 weeks later...

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...