Filter löschen
Filter löschen

Print Messages into Windows Command Window

20 Ansichten (letzte 30 Tage)
Rahul J Hirur
Rahul J Hirur am 3 Jun. 2022
Kommentiert: Rahul J Hirur am 4 Jun. 2022
Hello all,
I am running a Matlab script in Windows Command Window. I want to print messages into the same windows Command Window where I initiated the Matlab script to run. I am trying to use 'system(echo Hello)' command but it prints the MATLAB Command Prompt in the background but Not in windows Command window.
Is there a way to achieve this way of printing in CMD window?
Has anyone encounter this obstacle before or has anyone tried this approach before?

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 3 Jun. 2022
Use System.Diagnostics.Process to start CMD, and connect up standard input. When appropriate send CMD an ECHO command.
  1 Kommentar
Rahul J Hirur
Rahul J Hirur am 4 Jun. 2022
I tried your solution. It works where it opens up a Windows command prompt and prints the message in Windows command prompt.
The problem is when I open up a command prompt and call the script(seen below) it opens up another new windows command prompt and prints the message in it.
I want it to print the message in the same windows command prompt where I call the m script?
Processx = System.Diagnostics.Process;
Processx.StartInfo.CreateNoWindow=false;
Processx.StartInfo.UseShellExecute = false;
Processx.StartInfo.FileName = 'C:\Windows\System32\cmd.exe';
Processx.StartInfo.LoadUserProfile=true;
Processx.StartInfo.RedirectStandardInput=true;
Start(Processx)
Processx.StandardInput.WriteLine('echo Hello World, from inside matlab');
pause(10)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by