Reputation: 65
I wanted to run a nircmd process in my C# project (Windows Forms Application) so i went like this:
Process mute_process = new Process();
mute_process.StartInfo.FileName = "C:\\(**my path**)\\nircmd.exe mutesysvolume 1 ";
mute_process.Start();
Unfortunatelly my program throws error:
"Unhandled exception has occured in your aplication. If you click Continue, the application will ignore this error [...] The system cannot find the file specified."
Other processes in my C# program work for me (for example running mp3 file from a specific directory). Also, the nircmd process itself works well in the cmd. What am I doing wrong?
Upvotes: 0
Views: 1061
Reputation: 19526
That's because you included command line arguments in the filename property. You can use this approach instead:
Process mute_process = Process.Start("C:\\(**my path**)\\nircmd.exe", "mutesysvolume 1");
...or if you want to continue using StartInfo
, you can do this:
Process mute_process = new Process();
mute_process.StartInfo.FileName = "C:\\**my path**)\\nircmd.exe";
mute_process.StartInfo.Arguments = "mutesysvolume 1";
mute_process.Start();
Upvotes: 1