Matt
Matt

Reputation: 45

Run CMD from C# Console Application?

How might I run CMD.EXE from my C# Console Aplication? Like in Powershell you can run cmd.exe by typing "cmd"

EDIT: Open Powershell. Type "cmd". That's what I want.

EDIT2: Thank you for your help. I will try to make it clearer. I want it so that when the user enters "cmd" into my command line C# Application, it runs CMD.EXE in that same window. it is basically the same as typing CMD in Powershell.

Upvotes: 2

Views: 4712

Answers (2)

Eric
Eric

Reputation: 19863

I think that you want your user to have an interactive shell inside your application.

One way to do that is to redirect both stdin and stdout of cmd.exe to your application. It will input/output data from console in a string so you can show it in a textbox of whatever flots your boat.

This project from code project seems to do what you want to do

Upvotes: 3

The Smallest
The Smallest

Reputation: 5773

is Process.Start("cmd.exe") is what you're seeking for? (Don't forget to add using System.Diagnostics))
More info about Process class on MSDN

Upvotes: 4

Related Questions