Fixed bug constructing command-line for elevated process in .NET 5 (#784)

pull/972/head v2.11.0
Richard Fawcett 2021-03-17 16:01:17 +00:00 committed by GitHub
parent 2edcee7f49
commit e380e6c64e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 8 deletions

View File

@ -601,19 +601,15 @@ namespace WinSW
string? stderrName = Console.IsErrorRedirected ? Guid.NewGuid().ToString() : null;
#endif
string arguments = "/elevated " +
string exe = Environment.GetCommandLineArgs()[0];
string commandLine = Environment.CommandLine;
string arguments = "/elevated" +
#if VNEXT
" " + (stdinName ?? NoPipe) +
" " + (stdoutName ?? NoPipe) +
" " + (stderrName ?? NoPipe) +
#endif
#if NET
string.Join(' ', args);
#elif !NET20
string.Join(" ", args);
#else
string.Join(" ", args.ToArray());
#endif
commandLine.Remove(commandLine.IndexOf(exe), exe.Length).TrimStart('"');
var startInfo = new ProcessStartInfo
{