我会做其他管理它的应用程序......就像看门狗
这个应用程序将检查文件夹并重新启动主应用程序,并且应该可以配置为要求重新启动或不重新启动,并在一个时间范围内进行重新启动......(¿每天下午12:00?)
要杀死一个进程:
Process []pArry = Process.GetProcesses();
foreach(Process p in pArry)
{
if (p.ProcessName.CompareTo("yourapp") ==0)
{
p.Kill();
break;
}
}
p.WaitForExit(); // This is blocking so be careful, maybe it should be run in other thread
要启动一个进程:
Process.Start(path);
您应该知道您的应用程序的流程应该是:
1. Is a good time to patch the app?
1.1 NO-> Sleep for some time to recheck (¿12h?) and goto 1
2. Is there a new path?
2.1 NO-> Goto 1.1
3. Kill the main process
4. Apply the patch
5. Restart app
6. Goto 1