2

I need to copy some large sets of files from one server to another (DICOM imagesets). I've written a batch file to automate the process. The batch file reads a text file with a list of cases to copy and then runs a command to copy each one. This basically works.

The /WAIT option is supposed to make START wait until an application completes before proceeding. I'm using START /WAIT to run the program which copies the files. But, START /WAIT only seems to actually wait a maximum of 5 minutes.

In my scenario, this works okay for smaller cases, for which the next one will begin copying immediately after the previous one finishes. But, for larger cases, 5 minutes is not enough time to finish, and so multiple cases wind up copying at the same time. This causes problems, in particular cases not getting copied completely.

I've tried using the /B option with START. This fails in a different way. Specifically, a program running longer than 5 minutes terminates instead of being allowed to run concurrently.

For the record, I'm trying to run this on Windows 10, but I've had the same problem with Windows 7.

The following is the code I'm using:

@echo off
REM Usage - copylist filename.txt > copylog.txt

if exist %1 (
  echo File %1 found.
  for /f "tokens=*" %%i in (%1) do (
    echo "Copying %%i"
    START "%%i" /WAIT "c:\conquest\dgate.exe" --movepatient:X-server,Y-server,%%i
  ) 

) else (
  echo File was not found.
)
  • 1
    I have used START with /WAIT in several setups and have never experienced that the call returns before the started process has finished. Could it be that the dgate.exe process starts another process to do some of the work, and then terminates, or that the dgate.exe process simply terminates before the work is done, leaving cases not being completely copied? Have you tried monitoring the Task Manager while the script is running, to see of the dgate.exe process actually keeps running when the START command returns? – Lars Lind Nilsson Mar 18 '16 at 12:48
1

I cannot reproduce the 5 minute timeout on either windows 7 or 10. (I went as far as 15 minutes).

Why use START at all? Have you tried the snippet below? Looks like you get a new command processor, and a window title from START. Perhaps you can do it all in the original command?

@echo off
REM Usage - copylist filename.txt > copylog.txt

if exist %1 (
  echo File %1 found. 
  for /f "tokens=*" %%i in (%1) do (
    echo "Copying %%i"
    title "Copying %%i"
    c:\conquest\dgate.exe --movepatient:X-server,Y-server,%%i
  ) 

) else (
  echo File was not found.
)
0

START command with the /WAIT parameter does not use any time-out parameter, so, I can confirm that the issue is indeed not caused by the command timing out after 5 minutes (or some other interval).

/B option, on another hand, is also not something you would want to use in this case, as it does not cause any waiting on the child process.

You might want to start Process Monitor and capture a trace on the scenario where it takes longer to complete and starts another task while the first one is not finished. Once you have the trace (feel free to attach it here as well), you can Process Tree function (CTRL+T) to see what is happened with your processes. It is most likely that the issue is not with START /WAIT command, but with the dgate.exe application you have.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.