Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Main(string[] args)
- {
- try
- {
- string process = args[1].Replace(".exe", "");
- Console.WriteLine("Terminate process!");
- while (Process.GetProcessesByName(process).Length > 0)
- {
- Process[] myProcesses2 = Process.GetProcessesByName(process);
- for (int i = 1; i < myProcesses2.Length; i++)
- {
- myProcesses2[i].Kill();
- }
- Thread.Sleep(300);
- }
- if (File.Exists(args[1]))
- {
- File.Delete(args[1]);
- }
- File.Move(args[0], args[1]);
- Console.WriteLine("Starting " + args[1]);
- Process.Start(args[1]);
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.Message);
- Console.ReadKey();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement