- Home /
How do I access command prompt from Unity
I need to access command prompt to send it a command for phamtomJS to run a javascript file. So I need to tell command prompt to send this command at a certain point in the game and I'm not sure how I would have unity access command prompt to do this. I hope that was not too confusing. Any help would be great. Thanks
Answer by gbelini · Jan 02, 2013 at 04:32 PM
Hi, if i understand what you need, you could try this:
void Start()
{
string strCmdText;
strCmdText= "/C notepad"; //This command to open a new notepad
System.Diagnostics.Process.Start("CMD.exe",strCmdText); //Start cmd process
}
Thank you very much. So far that seems to work very well. You saved me alot of searching. Thanks again.
Answer by yogha001 · Dec 03, 2019 at 10:12 AM
I'm using almost the same Method, it works in Play Mode. But when I build my Project this will not gone work. Anybody had a similar Problem? I would be so grateful for that
void Start()
{
string strCmdText;
strCmdText = "ykush3 -u " + Port.ToString(); //This command to open a new notepad
System.Diagnostics.Process.Start(ApplicationPath + "\\hubControl\\ykushcmd.exe", strCmdText); //Start cmd process
}
Wild guess. When your app is built. that is then the wrong path
Yeah you‘re Right. I used to change the hubControl path inside my Strea$$anonymous$$gAssetss Path. And it did work ;) That was a long time ago! But thank you :)
void Start() { string strCmdText; strCmdText = "ykush3 -u " + Port.ToString(); //This command to open a new notepad System.Diagnostics.Process.Start(ApplicationPath + "\\Strea$$anonymous$$gAssests\\hubControl\\ykushcmd.exe", strCmdText); //Start cmd process }