close terminal window
4 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I make a program wich open the terminal window(C:\WINDOWS\system32\cmd.exe) at each time it's fired. I use it in a loop, so I got many useless terminal windows.
My question is : how to close a terminal window from matlab.
Greetings, Steven
7 件のコメント
Titus Edelhofer
2011 年 11 月 7 日
Hi Steven,
O.K., I see. How do you call the other program (system? Using "!"?)
Titus
採用された回答
その他の回答 (3 件)
Fangjun Jiang
2011 年 11 月 7 日
Assume you run your MATLAB code as system('MyProgram.exe') and it brought up that ugly black window but never exits, you can do this:
system('MyProgram.exe < Exit.txt'), where Exit.txt is a text file you created ahead of time. The text file contains one line, which is 'exit' without both the single quotes.
2 件のコメント
Fangjun Jiang
2011 年 11 月 7 日
So, you are using system(), right? Maybe I should emphasize that the text file should contain the text "exit" and then a carriage return. As if you are doing it manually. In one of the open command window, if you type exit and then return, it will close the window, right?
Steven
2011 年 11 月 7 日
7 件のコメント
Fangjun Jiang
2011 年 11 月 7 日
I don't understand. You still have not answered the question how your program brought up the Cmd window. See this post yourself.
http://www.mathworks.com/matlabcentral/answers/19793-using-system-to-run-an-executable-outside-of-matlab
Fangjun Jiang
2011 年 12 月 20 日
It should be the less than sign "<", not the greater than sign ">"!!!
Martijn van Sluis
2018 年 2 月 15 日
編集済み: Martijn van Sluis
2018 年 2 月 15 日
Perhaps not so elegant, but if you incorporate the following it works just fine:
keyInject('C:\Windows\system32\cmd.exe','exit','C:\Windows\system32\cmd.exe');
keyInject('C:\Windows\system32\cmd.exe','\r','C:\Windows\system32\cmd.exe');
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Startup and Shutdown についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!