dotnet / dotnet/runtime

[Process] Start process as non-elevated user

Open
#128,378 13 comments 3 reactions 0 assignees View on GitHub
api-suggestion area-System.Diagnostics.Process
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

### Background and motivation

Today I've been studying some MSFT source code and I got to the conclusion that we most likely need to add the ability to start process as non-elevated user when running as elevated user.

One way of doing that on Windows would be to use following sys-calls:
- https://learn.microsoft.com/en-us/windows/win32/api/winsafer/nf-winsafer-safercreatelevel
- https://learn.microsoft.com/en-us/windows/win32/api/winsafer/nf-winsafer-safercomputetokenfromlevel
- https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessasusera

### API Proposal

The proposal is to extend `ProcessStartInfo` with a new `StartNonElevated ` property that indicates the process should be started as non-elevated user.

```csharp
namespace System.Diagnostics;
{
public sealed class ProcessStartInfo
{
public bool StartNonElevated { get; set; }
}
}
```

Any feedback is welcome!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.