I want to execute command to call microphone config.
control mmsys.cpl,,1
I try following code but I throw Win32Exception, The system cannot find the file specified.
Process.Start("control mmsys.cpl,,1");
It should be:
Process.Start("control","mmsys.cpl,,1")
Documentation: http://msdn.microsoft.com/en-us/library/h6ak8zt5.aspx
You can try this -
Process cmd = new Process();
cmd.StartInfo.FileName = "cmd.exe";
cmd.StartInfo.RedirectStandardInput = true;
cmd.StartInfo.RedirectStandardOutput = true;
cmd.StartInfo.CreateNoWindow = true;
cmd.StartInfo.UseShellExecute = false;
cmd.Start();
/* execute "dir" command */
cmd.StandardInput.WriteLine("dir");
cmd.StandardInput.Flush();
cmd.StandardInput.Close();
Console.WriteLine(cmd.StandardOutput.ReadToEnd());
cmd.Close();
You can write your command to a bat file and execute it from the command prompt using the above method.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.