我正在尝试使用 CreateProcess 从我的应用程序中启动一个 powershell 脚本。
我使用了 Microsoft 示例(http://msdn.microsoft.com/en-us/library/ms682499(VS.85).aspx)来创建子进程并重定向标准的 out/in/err 管道。
剩下要解决的唯一问题是为什么子进程(powershell)在执行命令后没有终止。
如果我执行 powershell 进程(使用命令) cmd.exe 它执行并退出,关闭进程。
现在关闭powershell进程的唯一方法是在句柄上运行TerminateProcess,但这感觉像是最后的手段。