Search code examples
batch-filecmdcallzombie-process

Call CMD START copy - background zombie process


After running the following script, it leaves behind 4 zombie cmd processes. Any explanation for this, and how can I make the processes exit?

call cmd /c start /b copy /y "%VIP_PATH%\*.txt" "P:\"
call cmd /c start /b copy /y "%VIP_PATH%\*.doc" "P:\"

call cmd /c start /b copy /y "%VIP_PATH%\*.xls" "P:\"
call cmd /c start /b copy /y "%VIP_PATH%\*.pdf" "P:\"

Solution

  • The "problem" is that when you invoke start /b with an internal command as argument (copy in your case), what gets executed is

     "%comspec%" /k yourCommand
    

    That is, the command processor is executed with the instruction to keep it open.

    Try with

    start /b "" cmd /c copy /y "%VIP_PATH%\*.txt" "P:\"