- Home /
How do I tell command prompt to do a command after I open it through Unity?
I am able to open command prompt from unity but I cannot figure out how to have unity give Command Prompt a command after I open it. And I'm not trying to tell it to open a program. I have been able to open notepad with the following code. But I'm trying to simply have a command entered into cammand prompt after it is opened and executed without the user having to input it into command prompt themselves. Any ideas?
funciton Start()
{
var strCmdText: String;
strCmdText= "/C notepad"; //This command to open a new notepad
System.Diagnostics.Process.Start("CMD.exe",strCmdText); //Start cmd process
}
Comment
Answer by dubbreak · Feb 16, 2013 at 03:31 AM
Two ways.
1 - The way you are doing it (but hide the window). So each time you want to run a cmd populate a string with the command and run your
System.Diagnostics.Process.Start("CMD.exe",cmdText);
Example here.
2 - If you want an actual interactive session with the terminal (but with it hidden) you'll want to do something like this.