The goal is to have a console application which is able to start a process without opening it in a new window.
This is the working code in .net 4.6, which I am testing by launching notepad.exe
:
ProcessStartInfo startInfo = new ProcessStartInfo()
{
WorkingDirectory = exeFileInfo.Directory.FullName,
FileName = exeFileInfo.Name,
Arguments = cmdStr,
CreateNoWindow = true,
UseShellExecute = true,
WindowStyle = ProcessWindowStyle.Hidden
};
When translating it to dotnet core there are two issues with this same code:
- Compilation error:
'ProcessStartInfo' does not contain a definition for 'WindowStyle'
- Runtime exception:
System.PlatformNotSupportedException: 'UseShellExecute must always be set to false.'
.
Is there any way to execute a hidden process? (at least in Windows).