To reproduce your problem, I used the following program:
using System;
using System.ComponentModel;
using System.Diagnostics;
public class Test
{
public static int Main()
{
string error;
try {
ProcessStartInfo i = new ProcessStartInfo();
i.FileName = @"C:\long file path\run.cmd";
i.WindowStyle = ProcessWindowStyle.Hidden;
i.UseShellExecute = true;
i.RedirectStandardOutput = false;
using (Process p = Process.Start(i)) {
error = "No process object was returned from Process.Start";
if (p != null) {
p.WaitForExit();
if (p.ExitCode == 0) {
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("OK");
Console.ResetColor();
return 0;
}
error = "Process exit code was " + p.ExitCode;
}
}
}
catch (Win32Exception ex) {
error = "(Win32Exception) " + ex.Message;
}
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Whooops: " + error);
Console.ResetColor();
return 1;
}
}
The code starts a new process (according to your sample code) and reports on various ways to execute it. You can compile the program from the command line:
c:\windows\Microsoft.NET\Framework\v2.0.50727\csc test.cs
(, test.cs , test.exe , test.cs)
, "C:\long file path\run.cmd" , :
Whooops: (Win32Exception) The system cannot find the file specified
"C:\long file path" run.cmd:
rem file run.cmd
echo I ran at %Time% > "%~dp0\run.out.txt"
. run.cmd test.exe (.. Run.cmd - , "C:\long file path\run.out.txt".
test.exe Vista x64 ( ), Windows XP SP3 x86 ( ), Windows Server 2008 x64 ( ) .
, ? , , , ( .NET , ).