Hello!
I am trying to execute a command in cmd.exe using C#.
Normally, I would open the cmd.exe prompt manually and I would go the the directory: "C:\myproject" which is the directory I need to first select.
Secondly, I would manually run the command: "node fileWithCommands.js" which is a ".js" file which exists in the "C:\myproject" directory. I would then VISUALLY see commands executing in the actual cmd window that is opened.
So now I am trying to emulate this above manual task by executing that using C#. But the cmd window is only opening with "C:\myproject" selected and the below command is not executing?
Thank you!
Code not executing?
p.StartInfo.Arguments = "node fileWithCommands.js";
Complete code:
Process p = new Process();
p.StartInfo.FileName = "C:\\Windows\\system32\\cmd.exe";
p.StartInfo.WorkingDirectory = @"C:\myproject";
p.StartInfo.Arguments = "node fileWithCommands.js";
p.Start();