Start system command or run batchfile in background

조회 수: 82 (최근 30일)
Samuel de Vries
Samuel de Vries 2017년 12월 15일
답변: Samuel de Vries 2017년 12월 18일
Hi,
In short I am trying to run a series of batchfiles in parallel inside a for loop by using system('start my command iteration i'). I use this 'start' option to make Matlab run the system command but not wait for the command to complete and effectively run these commands in parallel (as described in an earlier forum question) .
system('start illum_204_4_18_13.bat')
This works as it should and saves computation time compared to running in series using.
system('illum_204_4_18_13.bat').
However I am not able to supress to command prompt windows from popping up. I read that adding an '&' at the end of my command should solve this but I have been unsuccessfull in applying this.
Running the following makes two command prompt windows pop up:
system('start illum_204_4_18_13.bat &')
I have already tried using Matlab's built in parallel processing capabilities (parfor) with the system('my command') method but Matlab's parallel overhead makes the script slower than doing it in series.
Kind regards,
Samuel

채택된 답변

Samuel de Vries
Samuel de Vries 2017년 12월 18일
The solution was to run the batchfiles as following: system('start /b yourbatchfile.bat'). The /b will prevent the command shell from opening a new window. I realise now that this question was more of a windows command shell question than a Matlab one.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by