Reputation: 63
I'm trying to exe batch file from C# console. The following code doesn't work. I'd like to know what's wrong with my ProcessStartInfo configuration.
String cmd = "/C "+ path2watch + "\\batch.bat";
ProcessStartInfo psi = new ProcessStartInfo()
{
CreateNoWindow = true,
UseShellExecute = false,
FileName = @"cmd.exe",
Arguments = cmd,
RedirectStandardError = true,
RedirectStandardOutput = true,
ErrorDialog = false
};
Process p = Process.Start(psi);
p.WaitForExit();
Thanks
Upvotes: 0
Views: 395
Reputation: 63
The problem what that I didn't set the working directory Property. I've set the working directory to the wanted path. But it's still strange why cd didn't overcome "the working directory" issue
Upvotes: 1