Trying to make a script to unlock all locked files inside a folder, by using Windows' handle.exe. But when I split the output the filename value is .... weird (all other values are Ok).
The sample output of the handle.exe is this:
REM perl.exe pid: 12532 type: File PCNAME\UserName 144: C:\dev\massunlocker\Eula.txt
REM a perl.exe
REM b pid:
REM c 12532
REM d type:
REM e File
REM f PCNAME\UserName
REM g 144:
REM h C:\dev\massunlocker\Eula.txt
So, from this I need c, g, and h.
@echo off
setlocal EnableDelayedExpansion
for /f "tokens=1,2,3,4,5,6,7,8 delims= " %%a in ( 'handle64.exe C:\dev\massunlocker\sample-dir -u -nobanner' ) do (
REM echo a = "%%a"
REM echo b = "%%b"
REM echo c = "%%c"
REM echo d = "%%d"
REM echo e = "%%e"
REM echo f = "%%f"
REM echo g = "%%g"
REM echo h = "%%h"
echo [%%h]
)
:end
setlocal DisableDelayedExpansion
First 2 are fine, but the %%h is hmm weird (edited)?
]C:\dev\massunlocker\sample-dir\ae\pdf
]C:\dev\massunlocker\sample-dir
]C:\dev\massunlocker\sample-dir\ae
Why its not this? :
[C:\dev\massunlocker\sample-dir\ae\pdf]
[C:\dev\massunlocker\sample-dir]
[C:\dev\massunlocker\sample-dir\ae]
And I can't test it for being dir or a file, it's always comes as true for not exist, for example.
Edit: here's an output example with lines uncommented:
a = "cmd.exe"
b = "pid:"
c = "1624"
d = "type:"
e = "File"
f = "PCNAME\UserName"
g = "1FC:"
" = "C:\dev\massunlocker\sample-dir
note the last line...
P.S. Handle tool

partial.