In .NET, how do you send multiple arguments into a DOS command prompt?
        Posted  
        
            by donde
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by donde
        
        
        
        Published on 2010-06-01T15:49:03Z
        Indexed on 
            2010/06/01
            15:53 UTC
        
        
        Read the original article
        Hit count: 261
        
I am trying to execute DOS commands in ASP.NET 2.0. What I have now calls a BAT file which, in turn, calls a CMD file. It works (with the end result being a file gets ftp'ed). However, I'd like to dump the BAT and CMD files and run everything in .NET. What is the format of sending multiple arguments into the command window? Here is what I have now.
The .NET Code:
    System.Diagnostics.Process proc = new System.Diagnostics.Process();
    proc.EnableRaisingEvents = false;
    proc.StartInfo.FileName = "C:\\MyBat.BAT";
    proc.Start();
    proc.WaitForExit();
The Bat File looks like this (all it does is run the cmd file):
ftp.exe -s:C:\MyCMD.cmd
And here is the content of the Cmd file:
open <my host>
<my user name>
<my pw>
quote site cyl pri=1 sec=1 lrecl=1786 blksize=0 recfm=fb retpd=30
put C:\MyDTLFile.dtl 'MyDTLFile.dtl'
quit
© Stack Overflow or respective owner