目标是拥有一个控制台应用程序,无需在新窗口中打开它即可启动进程。
这是.net 4.6中的工作代码,我正在通过启动notepad.exe
进行测试:
ProcessStartInfo startInfo = new ProcessStartInfo()
{
WorkingDirectory = exeFileInfo.Directory.FullName,
FileName = exeFileInfo.Name,
Arguments = cmdStr,
CreateNoWindow = true,
UseShellExecute = true,
WindowStyle = ProcessWindowStyle.Hidden
};
将其翻译为dotnet核心时,同一代码存在两个问题:
'ProcessStartInfo' does not contain a definition for 'WindowStyle'
System.PlatformNotSupportedException: 'UseShellExecute must always be set to false.'
。有没有办法执行隐藏进程? (至少在Windows中)。