Fixed bug constructing command-line for elevated process in .NET 5

pull/784/head
Yeurch 2021-01-25 14:40:27 +00:00 committed by Next Turn
parent 2edcee7f49
commit db994d06aa
No known key found for this signature in database
GPG Key ID: 6A02A6770B9A88A0
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
{