我试图通过 C# 代码打开 Powershell,最终目标是通过 C# 编写命令行(不使用 powershell skript)。
我做了一些研究并提出了这个代码片段,但由于某种原因它只是没有打开 Powershell。Powershell 打开的代码需要改什么?
//Opening Powershell
private void Execute()
{
ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = @"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe",
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true,
};
Process pro = Process.Start(startInfo);
pro.WaitForExit();
Thread.Sleep(3000);
pro.Close();
}
收到一只叮咚
相关分类