close command / dos window
조회 수: 84(최근 30일)
Kevin Rawson 2019년 4월 7일
Simplest way without modifying your original batch file would be to add an exit command to your system call.
system('yourScript.bat && exit &')
This will complete execution of "yourScript.bat" in a new DOS command window, and then close the spawned window.
dpb 2017년 6월 5일
If you must use the trailing '&' to dispatch the command window to the background while the Matlab system continues, then you don't have control of that window with just the supplied system. Others have shown a way to kill a process; the alternate would be to add an EXIT command as the last entry in the .bat file to close the session when the routine terminates.
Nagesh 2017년 1월 11일
편집: Walter Roberson 2017년 1월 12일
let's say you want to kill both your progam (yourprogram.exe) and the cmd window that gets opened with the system command, you can use the following command
[status1]=system('"C:\Windows\System32\taskkill.exe" /F /im yourprogram.exe /im cmd.exe &');
This will kill 'yourprogram' and also closes 'cmd' window