Sch*_*uge 23 powershell process
我需要调用外部应用程序(即&'Notepad'),然后获取被调用应用程序的进程ID.
Get-Process Notepad =将返回所有记事本进程
我想做的事情如下:
$objApp = & 'c:\Notepad.exe'
WHILE (get-process -ID $objApp.id | select -property Responding) {
Start-Sleep -s 10
Echo "STILL WAITING"
}
Echo "Done!!"
Run Code Online (Sandbox Code Playgroud)
zda*_*dan 46
使用这样Start-Process
的-PassThru
参数:
$app = Start-Process notepad -passthru
Wait-Process $app.Id
Run Code Online (Sandbox Code Playgroud)
更简洁:
# Starts Notepad and returns the ID
(Start-Process Notepad -passthru).ID
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
34806 次 |
最近记录: |