Error when using dos to open firefox browser

1 回表示 (過去 30 日間)
Ara
Ara 2015 年 3 月 11 日
コメント済み: Ara 2015 年 3 月 14 日
I want to open firefox browser with this code. --> dos('start http://translate.google.com/translate_tts?tl=en&q=Hello world');
but it got error like this --> 'q' is not recognized as an internal or external command, operable program or batch file.
How to solve it. Thank you everyone

採用された回答

Brendan Hamm
Brendan Hamm 2015 年 3 月 11 日
& is a special character in batch scripting. You need to pass in the URL in quotes and pass an empty quote in front of it for the title.
dos('start "" "http://translate.google.com/translate_tts?tl=en&q=Hello world"');
  3 件のコメント
Brendan Hamm
Brendan Hamm 2015 年 3 月 13 日
The first "" is just the title for display in the window title bar. That is the start command opens a new command window and the title of it will be whatever is in this string. However the path we specify is a url and therefore windows opens the appropriate application instead, so title is not even useful here. In the dos command window you can type:
help start
for more information on the start command. We are not interested in the tile for the window anyhow as we are opening our web browser. For your second question you would want to use:
>> url = '"http://translate.google.com/translate_tts?tl=en&q=Hello world"'
url =
"http://translate.google.com/translate_tts?tl=en&q=Hello world"
As you can see the return value includes the quotation character in the string. Now just passing url to the dos command is not enough as we are still missing pieces from my above post. Now we need to concatenate url with the rest of the input:
str = ['start "" ', url]; % Creates the literal string I pass to dos in above post
dos(str);
Hope this helps explain the why.
Ara
Ara 2015 年 3 月 14 日
It's very helpful. Thank you for your help :)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePlatform and License についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by