PowerShell - 获取被调用应用程序的进程 ID [英] PowerShell - get process ID of called application
本文介绍了PowerShell - 获取被调用应用程序的进程 ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要调用外部应用程序(即 & 'Notepad' )然后获取被调用应用的进程ID.
I need to call an external application (i.e. & 'Notepad' ) and then get the process ID of the called application.
Get-Process Notepad = 将返回所有记事本进程
Get-Process Notepad = will return all Notepad processes
我想做类似的事情:
$objApp = & 'c:\Notepad.exe'
WHILE (get-process -ID $objApp.id | select -property Responding) {
Start-Sleep -s 10
Echo "STILL WAITING"
}
Echo "Done!!"
推荐答案
将 Start-Process
与 -PassThru
参数一起使用,如下所示:
Use Start-Process
with the -PassThru
argument like this:
$app = Start-Process notepad -passthru
Wait-Process $app.Id
这篇关于PowerShell - 获取被调用应用程序的进程 ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文