【发布时间】:2017-04-26 19:13:37
【问题描述】:
我有以下代码
Start-Process -windowstyle minimized "C:/xampp/xampp-control.exe"
有办法知道进程是否已经在运行?
【问题讨论】:
标签: powershell prompt
我有以下代码
Start-Process -windowstyle minimized "C:/xampp/xampp-control.exe"
有办法知道进程是否已经在运行?
【问题讨论】:
标签: powershell prompt
一种方法是获取进程的进程ID(使用Start-Process的-PassThru参数),然后您可以通过ID查看进程是否存在。示例:
$processId = (Start-Process notepad -PassThru).Id
if ( Get-Process -Id $processId -ErrorAction SilentlyContinue ) {
"Process is running"
}
【讨论】: