Skip to content

[Breaking change]: ProcessStartinfo.WindowsStyle is now honored with UseShellExecute = false #37739

@jozkee

Description

@jozkee

Description

Historically, WindowStyle was only honored when used with UseShellExecute = true.

using System.Diagnostics;

ProcessStartInfo startInfo = new()
{
    FileName = @"C:\Windows\System32\notepad.exe",
    UseShellExecute = false,
    WindowStyle = ProcessWindowStyle.Hidden
};

var process = Process.Start(startInfo);
process!.WaitForExit();

Version

.NET 8 Preview 6

Previous behavior

The Process would start as if you haven't specified a WindowStyle.

New behavior

WindowStyle is now honored even for Processes started with UseShellExecute = false.

Type of breaking change

  • Binary incompatible: Existing binaries may encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
  • Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code may require source changes to compile successfully.
  • Behavioral change: Existing binaries may behave differently at run time.

Reason for change

Completeness. There were scenarios that require changing the style of the spawned process' window (specially hide it). see microsoft/playwright-dotnet#2623.

Recommended action

This change affects code that was specifying WindowStyle even when it wasn't properly supported, e.g. WPF's order of event firing will be altered now because proper support was implemented. See dotnet/wpf#8043.

The needed action to fully and quickly mitigate the breaking change is to not specify WindowStyle in ProcessStartInfo.

Feature area

Core .NET libraries

Affected APIs

The breaking change can be observed on System.Diagnostics.Process.Start (all overloads) that use the System.Diagnostics.ProcessStartInfo.WindowStyle API.


Associated WorkItem - 177281

Metadata

Metadata

Assignees

Labels

🏁 Release: .NET 8Work items for the .NET 8 release📌 seQUESTeredIdentifies that an issue has been imported into Quest.breaking-changeIndicates a .NET Core breaking change

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions