Write to "Command Line" by C#

Asked

Viewed 328 times

3

Boas, I have a program, which uses the command line, but I can only get it to write "one line", and I needed it to write more than one without erasing what has already been written...

What I got so far:

CODE

 private void button3_Click(object sender, EventArgs e)
    {
        using (System.Diagnostics.Process processo = new System.Diagnostics.Process())
        {
            processo.StartInfo.FileName = Environment.GetEnvironmentVariable("comspec");
            processo.StartInfo.WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            processo.StartInfo.Arguments = string.Format("/K IPCONFIG");
            processo.StartInfo.Arguments = string.Format("/K OPENSSL");

            processo.Start();
            processo.WaitForExit();
        }
    }

Thank you.

  • I don’t quite understand what you want and what the problem is.

  • The problem is that the program now opens the Command Line, does "IPCONFIG" and then does OPENSSL but deletes IPCONFIG...

2 answers

1

0

Maybe if you change your code:

processo.StartInfo.Arguments = string.Format("/K IPCONFIG");
processo.StartInfo.Arguments = string.Format("/K OPENSSL");

for that:

processo.StartInfo.Arguments = string.Format("/K IPCONFIG & /K OPENSSL");

Can solve your problem.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.