Answered Read Command Prompt

octola

New member
Joined
Jul 2, 2020
Messages
4
Programming Experience
Beginner
Hello,
I’m writing a code with a button in Outlook. When the button is triggered, I would like to launch the Windows command prompt and retrieve what the user writes in the command prompt.

I already have this piece of code which allows to write in the command prompt:

C#:
Process process = new Process();
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.Arguments = "cmd /k echo Enter your text";
process.StartInfo.UseShellExecute = false;
process.Start();

But I don’t know which line to write to retrieve what is then written in the command prompt. Does anyone have an idea?

Thank you in advance
 
Why not use the InputBox function? (add reference to Microsoft.VisualBasic)
C#:
var input = Microsoft.VisualBasic.Interaction.InputBox("enter text:");
 
John knows much more than me & obviously what's linked there is a better way, but for your curiousity to obtain in input from a user and store it as a variable:

C#:
string answer = Console.Readline()
 
Except it is not a console application.
 
Hello,
I’m writing a code with a button in Outlook. When the button is triggered, I would like to launch the Windows command prompt and retrieve what the user writes in the command prompt.

I already have this piece of code which allows to write in the command prompt:

C#:
Process process = new Process();
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.Arguments = "cmd /k echo Enter your text";
process.StartInfo.UseShellExecute = false;
process.Start();

But I don’t know which line to write to retrieve what is then written in the command prompt. Does anyone have an idea?

Thank you in advance
If you did want to go that way, this would be the place to start:

 
Back
Top Bottom