diff --git a/src/libraries/System.Diagnostics.Process/tests/ProcessStartInfoTests.cs b/src/libraries/System.Diagnostics.Process/tests/ProcessStartInfoTests.cs index e88bef5138f17a..f3c4f285590e0d 100644 --- a/src/libraries/System.Diagnostics.Process/tests/ProcessStartInfoTests.cs +++ b/src/libraries/System.Diagnostics.Process/tests/ProcessStartInfoTests.cs @@ -472,8 +472,11 @@ public void TestUserCredentialsPropertiesOnWindows() { p = CreateProcessLong(); - // ensure the new user can access the .exe (otherwise you get Access is denied exception) - SetAccessControl(username, p.StartInfo.FileName, add: true); + if (PlatformDetection.IsNotWindowsServerCore) // for this particular Windows version it fails with Attempted to perform an unauthorized operation (#46619) + { + // ensure the new user can access the .exe (otherwise you get Access is denied exception) + SetAccessControl(username, p.StartInfo.FileName, add: true); + } p.StartInfo.LoadUserProfile = true; p.StartInfo.UserName = username; @@ -500,10 +503,6 @@ public void TestUserCredentialsPropertiesOnWindows() } finally { - SetAccessControl(username, p.StartInfo.FileName, add: false); // remove the access - - Assert.Equal(Interop.ExitCodes.NERR_Success, Interop.NetUserDel(null, username)); - if (handle != null) handle.Dispose(); @@ -513,6 +512,13 @@ public void TestUserCredentialsPropertiesOnWindows() Assert.True(p.WaitForExit(WaitInMS)); } + + if (PlatformDetection.IsNotWindowsServerCore) + { + SetAccessControl(username, p.StartInfo.FileName, add: false); // remove the access + } + + Assert.Equal(Interop.ExitCodes.NERR_Success, Interop.NetUserDel(null, username)); } }