重新启动本身的应用 [英] Restart an application by itself
问题描述
我要建立我的功能应用到自己重新启动。我发现在$ C $的CProject
的ProcessStartInfo信息=新的ProcessStartInfo();
Info.Arguments =/ C选择/ CY / N / DY / T 3及删除+
Application.ExecutablePath;
Info.WindowStyle = ProcessWindowStyle.Hidden;
Info.CreateNoWindow = TRUE;
Info.FileName =cmd.exe的;
的Process.Start(信息);
Application.Exit();
这不工作在所有... 而另一个问题是,如何再次启动它这样吗? 也许也有争论启动应用程序。
编辑:
? 的http://www.$c$cproject.com/script/Articles/ArticleVersion.aspx援助= 31454&放大器; AV = 58703
我用类似code到code您试图重新启动应用程序时。我发送定时cmd命令,重新启动应用程序,对我来说是这样的:
的ProcessStartInfo信息=新的ProcessStartInfo();
Info.Arguments =/ C平127.0.0.1 -n 2及和放大器; \+ Application.ExecutablePath +\;
Info.WindowStyle = ProcessWindowStyle.Hidden;
Info.CreateNoWindow = TRUE;
Info.FileName =cmd.exe的;
的Process.Start(信息);
Application.Exit();
在命令发送到操作系统,平暂停脚本2-3秒,此时应用程序已经从 Application.Exit退出()
,然后在平之后的下一个命令再次启动它。
注: \
放在引号内的道路,以防它有空间,这在cmd无法处理不带引号
希望这有助于!
I want to build my application with the function to restart itself. I found on codeproject
ProcessStartInfo Info=new ProcessStartInfo();
Info.Arguments="/C choice /C Y /N /D Y /T 3 & Del "+
Application.ExecutablePath;
Info.WindowStyle=ProcessWindowStyle.Hidden;
Info.CreateNoWindow=true;
Info.FileName="cmd.exe";
Process.Start(Info);
Application.Exit();
This does not work at all... And the other problem is, how to start it again like this? Maybe there are also arguments to start applications.
Edit:
http://www.codeproject.com/script/Articles/ArticleVersion.aspx?aid=31454&av=58703
I use similar code to the code you tried when restarting apps. I send a timed cmd command to restart the app for me like this:
ProcessStartInfo Info = new ProcessStartInfo();
Info.Arguments = "/C ping 127.0.0.1 -n 2 && \"" + Application.ExecutablePath + "\"";
Info.WindowStyle = ProcessWindowStyle.Hidden;
Info.CreateNoWindow = true;
Info.FileName = "cmd.exe";
Process.Start(Info);
Application.Exit();
The command is sent to the OS, the ping pauses the script for 2-3 seconds, by which time the application has exited from Application.Exit()
, then the next command after the ping starts it again.
Note: The \"
puts quotes around the path, incase it has spaces, which cmd can't process without quotes.
Hope this helps!
这篇关于重新启动本身的应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!