Running External Command Prompt Through System Command Prompt
15 ビュー (過去 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 日 20:39
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!