Fix ProcUtils NoAssociatedProcess issue

This commit is contained in:
2dust 2025-02-04 10:30:33 +08:00
parent bccab41c8f
commit e986dc189e

View file

@ -24,18 +24,18 @@ public static class ProcUtils
if (arguments.Contains(' ')) if (arguments.Contains(' '))
arguments = arguments.AppendQuotes(); arguments = arguments.AppendQuotes();
Process process = new() Process proc = new()
{ {
StartInfo = new ProcessStartInfo StartInfo = new ProcessStartInfo
{ {
UseShellExecute = true, UseShellExecute = true,
FileName = fileName, FileName = fileName,
Arguments = arguments, Arguments = arguments,
WorkingDirectory = dir WorkingDirectory = dir ?? string.Empty
} }
}; };
process.Start(); proc.Start();
return process.Id; return dir is null ? null : proc.Id;
} }
catch (Exception ex) catch (Exception ex)
{ {