110,533
社区成员
发帖
与我相关
我的任务
分享
string[] args = { "/s /t 500", "ping www.xxx.com", "netstat -a", "ipconfig" };
foreach(string s in args)
{
//*.exe s
}
namespace 命令行参数
{
class Program
{
static void Main(string[] args)
{
foreach (var s in args)
{
Console.WriteLine(s);
}
}
}
}
static class Program
{
static System.Threading.Timer tmr;
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
var f = new Form2();
if (args.Contains("/s") && args.Contains("/t"))
{
var index = Array.IndexOf(args, "/t");
tmr = new System.Threading.Timer(x =>
{
f.ShutDown();
tmr.Dispose();
tmr = null;
}, null, int.Parse(args[index + 1]), 0);
}
Application.Run(f);
}
}