NewLife/Stardust

交互模式直接运行
大石头 authored at 2024-11-25 09:58:04
54a6900
Tree
1 Parent(s) dc750b3
Summary: 1 changed files with 12 additions and 3 deletions.
Modified +12 -3
Modified +12 -3
diff --git a/Stardust/Managers/ServiceController.cs b/Stardust/Managers/ServiceController.cs
index f2766aa..00ba08e 100644
--- a/Stardust/Managers/ServiceController.cs
+++ b/Stardust/Managers/ServiceController.cs
@@ -399,9 +399,18 @@ internal class ServiceController : DisposeBase
         // Windows桌面用户运行
         if (Runtime.Windows && service.UserName == "$")
         {
-            var desktop = new Desktop { Log = Log };
-            var pid = desktop.StartProcess(si.FileName, si.Arguments, si.WorkingDirectory);
-            p = Process.GetProcessById((Int32)pid);
+            // 交互模式直接运行
+            if (Environment.UserInteractive)
+            {
+                p = Process.Start(si);
+            }
+            else
+            {
+                // 桌面用户运行
+                var desktop = new Desktop { Log = Log };
+                var pid = desktop.StartProcess(si.FileName, si.Arguments, si.WorkingDirectory);
+                p = Process.GetProcessById((Int32)pid);
+            }
         }
         else
         {