在dotnet核心中启动隐藏进程

时间:2017-08-03 11:37:27

标签: c# .net .net-core

目标是拥有一个控制台应用程序,无需在新窗口中打开它即可启动进程。

这是.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核心时,同一代码存在两个问题:

  1. 编译错误:'ProcessStartInfo' does not contain a definition for 'WindowStyle'
  2. 运行时例外:System.PlatformNotSupportedException: 'UseShellExecute must always be set to false.'
  3. 有没有办法执行隐藏进程? (至少在Windows中)。

0 个答案:

没有答案