The problem is that you have UseShellExecute as false, but you are not passing the name of the executable.
When ShellExecute used, it looks like double-clicking on a file in Explorer - it knows that .doc files must be opened with Word and that .bat files need to be opened with cmd.exe . However, when you turned off this function, it does not know any of this, and you need to transfer the executable file so that everything runs successfully.
When you set the value of RedirectStandardOutput to true, you need to run the batch file via cmd.exe instead, setting the FileName to cmd.exe and the /C "c:\myFile.bat" :
p.StartInfo.FileName = "cmd.exe"; p.StartInfo.Arguments = "/C \"c:\\myFile.bat\"";
Justin
source share