Reputation: 21
This question has been asked before but I cannot find an answer that works. I need to get a C# CONSOLE program to restart periodically. Each of the other answers use the Application.Restart or Application.ExecutablePath which are not supported in console apps. What code or reference can I use to restart a C# application?
Upvotes: 1
Views: 9210
Reputation: 21
Found it:
var info = new System.Diagnostics.ProcessStartInfo(Environment.GetCommandLineArgs()[0]);
System.Diagnostics.Process.Start(info);
Upvotes: 1
Reputation: 621
This command will work:
System.Windows.Forms.Application.Restart();
But you need to make sure you added and referred to correctly assembly. It's System.Windows.Forms in Assembly.
Upvotes: 0