如何通过带参数的批处理文件调用控制台应用程序? [英] How to call console app by batch file with parameter?
本文介绍了如何通过带参数的批处理文件调用控制台应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我想通过批处理文件执行控制台应用程序.
实际该怎么做?如果我想将参数从批处理文件传递给此exe
可以吗?
我的控制台应用程序标头如下:-
Hi
I want to execute my console application by a batch file..
actually how to do that? and if i want to pass parameter from batch file to this exe
is it do able?
my console app header like below:-
static void Main(string[] args)
{
string ls_FileExt = "", ls_FileName = "";
DateTime ldt_CurrDateTime = System.DateTime.Now;
string[] files = Directory.GetFiles("C:\\A");
//-
}
通过CS
//--
}
By CS
推荐答案
为什么不使用Main
方法的args
参数?那正是...的用途.
可以给我展示一些例子,因为我在控制台应用程序和批处理文件中也不好"
批处理文件:
Why not use theargs
parameter of yourMain
method? That is exactly what it is there for...
"able to show me some example, becourse i am not good in console app and batch file also"
Batch file:
myAppName ParameterText MoreParameters
您的应用:
Your app:
static void Main(string[] args)
{
foreach (string arg in args)
{
Console.WriteLine(arg);
}
}
输出:
Output:
ParameterText
MoreParameters
使用Process
对象.
如何启动Windows应用程序(记事本)/从C#/.NET控制台应用程序调用批处理文件. [ ^ ]是一篇很好的文章,应该对您有所帮助.
Use aProcess
object.
How to launch Windows applications (Notepad) / Call Batch files from a C#/.NET console application.[^] is a good article that should help you out.
这篇关于如何通过带参数的批处理文件调用控制台应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文