Execution of the batch files.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kiranasileti
    New Member
    • Jun 2009
    • 1

    Execution of the batch files.

    Hi All,

    I need to run couple of batch files using the C# console application. I have implemented the following code.

    ProcessStartInf o psi = new ProcessStartInf o ( );
    psi.WindowStyle = ProcessWindowSt yle.Normal;
    psi.FileName = @”Gen.bat”;
    psi.Arguments = args;
    psi.UseShellExe cute = false;
    psi.RedirectSta ndardOutput = stdout;
    psi.WorkingDire ctory = Environment.Cur rentDirectory;
    Process process = new Process ( );
    process.StartIn fo = psi;
    process.Start ( );
    Process.WaitFor Exit();

    When i tried to execute from my local machine, i didn't get any problem. If i kept the application exe and the batch files in a shared folder of a server machine and i tried to access from client machine, i got the following error message.

    CMD.EXE was started with the above path as the current directory.
    UNC paths are not supported. Defaulting to Windows directory


    Any help would be appreciated.


    Thanks In advance
    Kiran
  • Fr33dan
    New Member
    • Oct 2008
    • 57

    #2
    The CMD application cannot be have it's working directory in a folder that is addressed using a UNC path, which are ones that start with "//".

    You could either change the working directory to one that is valid if it isn't important to your batch file. If it is then the only option I can think of would be to mount the server directory to a network drive and run it from there.

    Comment

    Working...