Batch - Wait for the end of a process
brucine Posted messages 24847 Registration date Status Member Last intervention -
Hello,
I am currently working on a batch file, at the beginning of which I launch an Excel file and my batch pauses, but I would like the batch to continue as soon as the file closes (even if other Excel files are open).
Is it possible?
2 answers
-
Hello,
If we anticipate the usage time of the file in question, is it timeout instead of pause?
https://ss64.com/nt/timeout.html-
Hello,
Thank you for the response.
But I know about timeout that I use anyway.
It was more of a practical question that allows me to take the time to make my changes to the file. When it is closed, the batch command resumes automatically...
Hello,
You have already reported the issue to me.
In the link I mentioned in <3>, if I cannot pretend to rename the file because it is open, the error branch times out for 5 seconds and goes back to this renaming test ad vitam aeternam as long as RENAME, file closed, no longer causes an error and thus continues the batch.
@echo off :start ren path-myxlsfile path-myxlsfile if errorlevel 1 goto errorline Rest of my batch goto end :errorline timeout /T 5 goto :start :end exit
-
-
Hello,
Thank you for the reply.
But I know about timeout that I use by the way.
It was more of a practical question that allows me to take the time to make my modifications to the file. When I close it, the batch command automatically resumes...
-
Various tips, some complex, for example drawing inspiration here from the latest contribution: the attempt to rename the file identically fails as long as it is open.
https://stackoverflow.com/questions/6969421/detecting-if-a-file-is-open-in-a-batch-file
-