Click here to Skip to main content
15,909,445 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all
thnx for all

this cod for restart program and verry good

C#
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();


how I can run method after restart Auto
Posted

1 solution

Odd sort of request, but the easiest way is to pass an argument to the Process.Start by setting the
C#
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();

You can then check your application arguments as part of the main Form constructor:
C#
string[] args = Environment.GetCommandLineArgs();
if (args.Length > 1 && args[1] == @"/AutoRun")
  {
  // Run your method
  }
 
Share this answer
 
Comments
ridoy 19-Oct-13 13:54pm    
5ed!
BillWoodruff 19-Oct-13 22:50pm    
5=>vote. How anyone could vote this response #1 is beyond moi.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900