From 280e66f457d3536d1f1beee399d1abf83c29db48 Mon Sep 17 00:00:00 2001 From: BookerLiu Date: Tue, 4 Apr 2023 18:07:27 +0800 Subject: [PATCH] :tada: every thing --- Plugins/EveryThing/EveryThingUtil.cs | 40 +++++++++++++++------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/Plugins/EveryThing/EveryThingUtil.cs b/Plugins/EveryThing/EveryThingUtil.cs index 7d23819..ab31e8c 100644 --- a/Plugins/EveryThing/EveryThingUtil.cs +++ b/Plugins/EveryThing/EveryThingUtil.cs @@ -23,6 +23,10 @@ namespace GeekDesk.Plugins.EveryThing private static long pageCount = 20; private static UInt32 ui = 0; + private static Process serviceProcess = null; + private static Process exeProcess = null; + + public static void EnableEveryThing() { string pluginsPath = Constants.PLUGINS_PATH; @@ -52,33 +56,29 @@ namespace GeekDesk.Plugins.EveryThing if (!enabled) { //启动服务 - using (Process p = new Process()) - { - p.StartInfo.FileName = everyThingPath; - p.StartInfo.UseShellExecute = true; - p.StartInfo.Verb = "runas"; - p.StartInfo.Arguments = " -svc"; - p.Start(); - } + serviceProcess = new Process(); + serviceProcess.StartInfo.FileName = everyThingPath; + serviceProcess.StartInfo.UseShellExecute = true; + serviceProcess.StartInfo.Verb = "runas"; + serviceProcess.StartInfo.Arguments = " -svc"; + serviceProcess.Start(); } Thread.Sleep(2000); processList = Process.GetProcesses(); //启动程序 - using (Process p = new Process()) + exeProcess = new Process(); + exeProcess.StartInfo.FileName = everyThingPath; + exeProcess.Start(); + int waitTime = 5000; + while (true && waitTime > 0) { - p.StartInfo.FileName = everyThingPath; - p.Start(); - int waitTime = 5000; - while (true && waitTime > 0) - { - Thread.Sleep(100); - waitTime -= 100; - p.CloseMainWindow(); - } - + Thread.Sleep(100); + waitTime -= 100; + exeProcess.CloseMainWindow(); } + } catch (Exception e) { @@ -102,6 +102,8 @@ namespace GeekDesk.Plugins.EveryThing EveryThing32.Everything_Exit(); } } + if (exeProcess != null) exeProcess.Kill(); + if (serviceProcess != null) serviceProcess.Kill(); }