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

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
exppost
Posts: 3
Joined: 05 Oct 2021 14:51

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

#1 Post by exppost » 04 Jan 2022 10:50

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)

ShadowThief
Expert
Posts: 1160
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

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

#2 Post by ShadowThief » 04 Jan 2022 17:32

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.

Post Reply