public void ExecuteCommandSync(object command) { try { string exepath; string AppPath = Request.PhysicalApplicationPath.Replace("http:\\", ""); ////Get the application path //exepath = Server.MapPath("Up2Wav.exe"); exepath = Server.MapPath("tmp/Up2Wav.exe"); string strCmd = exepath + " " + command; StreamWriter _testData = new StreamWriter(Server.MapPath("data.txt"), true); _testData.WriteLine(strCmd); System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", "/c " + strCmd); // The following commands are needed to redirect the standard output. // This means that it will be redirected to the Process.StandardOutput StreamReader. procStartInfo.RedirectStandardOutput = true; procStartInfo.UseShellExecute = false; // Do not create the black window. procStartInfo.CreateNoWindow = true; // Now we create a process, assign its ProcessStartInfo and start it System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.StartInfo = procStartInfo; proc.Start(); // Get the output into a string string result = proc.StandardOutput.ReadToEnd(); // Display the command output. Console.WriteLine(result); _testData.WriteLine(result); _testData.Close(); _testData.Dispose(); } catch (Exception objException) { // Log the exception } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)