avishle
avishle

Reputation: 63

c# run batch file doen't work

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();

Cd doesn't work

Thanks

Upvotes: 0

Views: 395

Answers (1)

avishle
avishle

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

Related Questions