How to run system with space within the cmd

12 ビュー (過去 30 日間)
hailiang shen
hailiang shen 2011 年 3 月 24 日
Dear All, I am trying to execute the following command in matlab windows OS. e.g. system('C:\program files\a.exe')
It seems the system command can only recognize 'c:\program'. My question is how can i make matlab know i want to execute the a.exe file. This exe file is a very large one, and i do not want to reinstall it.
Thanks for all your help, Hailiang

回答 (2 件)

Walter Roberson
Walter Roberson 2011 年 3 月 24 日
system('"C:\program files\a.exe"')

hailiang shen
hailiang shen 2011 年 3 月 25 日
Thanks for your help. It works if my a.exe does not have any input arguments.
However, i am further trying to call a.exe with some command line arguments. Please note, the input is not read into exe by scanf as the following c code: #include stdio.h int main(int argc, char **argv) { char str[100]; scanf("%s", str); printf("I get %s", str); return ( 0 ); }
With this code, i think we can apply input redirection as discussed in this link http://www.mathworks.com/matlabcentral/newsreader/view_thread/241352
However, what i am trying to do is to use the e.g. argv[1] directly. I hope i make my question clear. This exe is not open source, i cannot change anything outside.
Thanks
  1 件のコメント
Walter Roberson
Walter Roberson 2011 年 3 月 25 日
system(['"C:\program files\a.exe" argument1 argument2 <', inputfilename])

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by