Running External Command Prompt Through System Command Prompt
조회 수: 4 (최근 30일)
이전 댓글 표시
I am attempting to use Matlab to open a command prompt associated with a program installed on my computer, and execute a command in that window. The system function in Matlab only appears to control the Windows command prompt. Is there a way I can make Matlab directly open and issue commands in the external command prompt? Or is there a way to make Matlab open the Windows command prompt, and then have Windows open and run the external command prompt?
댓글 수: 0
채택된 답변
Walter Roberson
2023년 7월 19일
I recommend reading about System.Diagnostics.Process such as at https://www.mathworks.com/matlabcentral/answers/586706-how-to-redirect-standard-input-and-standard-output-using-net-system-diagnostics-process#answer_487475
This is a .NET facility for controlling processes.
댓글 수: 0
추가 답변 (1개)
John Schilling
2025년 2월 13일
A possibly more direct answer to your question is you can open cmd with /k flag and pass commands at launch, then finish with & to spawn cmd as a window rather than having it tied to the Matlab command window.
eg.
system('cmd.exe /k echo "hello world" & ')
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!