Page 1 of 1

Process cannot access the file as it is used by another process

Posted: 04 Jan 2022 10:50
by exppost
I am trying to create windows batch script to check the size of file after it is downloaded but it fails with this message. The Process cannot access the file as it is used by another process 2048 was unexpected at this time. Thanks in advance for any help.

Code -

@echo off
d:\wget.exe ...
Rem this wget process downloads tst_file.xml

set file="tst_file.xml"
set maxbytesize=2048

for /F "usebackq" %%A IN ('%file%') DO set size=%%~zA

if %size% LSS %maxbytesize% (echo file is less than 2KB)

Re: Process cannot access the file as it is used by another process

Posted: 04 Jan 2022 17:32
by ShadowThief
As was mentioned in https://stackoverflow.com/questions/705 ... er-process, it sounds like tst_file.xml is still open somewhere because every other line in the script that you posted works correctly, so there's some issue with the wget command trying to write to a file that's in use.