How to pass string to batch file through c# and how batch file will accept string argument? -
my scenario in c# project user pass path "c:\homedir\mydir"
batch file batch file should accept path , create directory @ specified path.
i don't know how pass string batch file through c# , how batch file accept string , process it.
create process , pass argument(s) through startinfo.arguments
property.
process proc = new process(); proc.startinfo.filename = //path bat file proc.startinfo.arguments = string.format("{0}", @"c:\homedir\mydir"); //set rest of process settings proc.start();
that load bat file , pass whichever arguments you've added. bat file can access arguments using %1
first argument, %2
second 1 etc...
Comments
Post a Comment