Skip to content

Commit

Permalink
Fixed bug constructing command-line for elevated process in .NET 5 (#784
Browse files Browse the repository at this point in the history
)
  • Loading branch information
yeurch authored Mar 17, 2021
1 parent 2edcee7 commit e380e6c
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/WinSW/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -601,19 +601,15 @@ void Elevate()
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
{
Expand Down

0 comments on commit e380e6c

Please sign in to comment.