我如何在运行程序后运行方法 [英] how I can run method after run my program
本文介绍了我如何在运行程序后运行方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨所有
thnx为所有
这个鳕鱼用于重启计划并且非常好
hi all
thnx for all
this cod for restart program and verry good
ProcessStartInfo Info = new ProcessStartInfo();
Info.Arguments = "/C ping 127.0.0.1 -n 10 && \"" + Application.ExecutablePath + "\"";
Info.WindowStyle = ProcessWindowStyle.Hidden;
Info.CreateNoWindow = true;
Info.FileName = "cmd.exe";
Process.Start(Info);
Application.Exit();
重启后如何运行方法Auto
how I can run method after restart Auto
推荐答案
奇怪的请求,但最简单的方法是通过设置
Odd sort of request, but the easiest way is to pass an argument to the Process.Start by setting the
ProcessStartInfo.Arguments property:
ProcessStartInfo Info = new ProcessStartInfo();
Info.Arguments = "/C ping 127.0.0.1 -n 10 && \"" + Application.ExecutablePath + "\"";
Info.WindowStyle = ProcessWindowStyle.Hidden;
Info.CreateNoWindow = true;
Info.FileName = "cmd.exe";
info.Arguments = @"/AutoRun";
Process.Start(Info);
Application.Exit();
然后,您可以检查您的应用程序参数作为主Form构造函数的一部分:
You can then check your application arguments as part of the main Form constructor:
string[] args = Environment.GetCommandLineArgs();
if (args.Length > 1 && args[1] == @"/AutoRun")
{
// Run your method
}
这篇关于我如何在运行程序后运行方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文