How to unlock files using handle.exe and process name?

You can use handle.exe once to list the PIDs and handles, then again multiple times to close each one.

Use the for /f command to loop through the result of the first command. I don't have a Windows machine handy to test on, but it should look something like this:

From a batch file:

for /F "tokens=3,6 delims=: " %%I IN ('handle.exe -accepteula TestPro.log') DO handle.exe -c %%J -y -p %%I

From the command-line:

for /F "tokens=3,6 delims=: " %I IN ('handle.exe -accepteula TestPro.log') DO handle.exe -c %J -y -p %I