asp.net - How to run cmd.exe using c# with multiple arguments? -
i using next code open .exe , pass argument it:
processstartinfo startinfo = new processstartinfo(); startinfo.filename = "cmd.exe"; startinfo.arguments = @"/k set inetroot=c:\depot&set corextbranch=surfacert_v2_blue_kit&c:\depot\tools\path1st\myenv.cmd"; process.start(startinfo);` which opens window below.
now need pass "sd sync dirs" gives me result , capture result variable.
to accomplish need pass 2 agruments in processstartinfo.arguments. how can add together sec argument in above code take care of in c# code.
since string seek this:
string[] myarguments = { "firstarg", "secondarg"}; process.start("cmd.exe", string.join(" ", myarguments)); where firstarg , secondarg arguments.
edit: oops forgot tell ,if argument contains spaces this(the illustration contains 1 argument spaces-first arg- , 1 without spaces-secondarg):
string[] myarguments = { "\"first arg\"", "secondarg" }; c# asp.net
No comments:
Post a Comment