Powershell:如何检查 Internet Explorer 的任何实例是否已在运行 [英] Powershell: how to check if any instance of internet explorer is already running

查看:67
本文介绍了Powershell:如何检查 Internet Explorer 的任何实例是否已在运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检查 Internet Explorer 的任何实例,即它的任何窗口,是否已经打开,以便我可以决定必须创建一个新对象还是必须附加到该 IE 窗口的现有进程.这是下面的代码:

I want to check if any instance of internet explorer, ie any window of it, is already opened or not so that i can decide that a new object has to be created or i have to attach to existing process of that IE window. This is the code below:

$ie = (New-Object -COM "Shell.Application").Windows()| ? { $_.Name -eq "Windows Internet    Explorer" }

我只想在 IE 的窗口已经打开时附加到 windows(),如果没有打开 IE 窗口,那么该行应该是这样的:

$ie = (New-Object -COM "Shell.Application")

推荐答案

尝试:

if (
     Get-Process iexplore -ea silentlycontinue | 
     Where-Object {$_.MainWindowTitle -ne ""}
)

这篇关于Powershell:如何检查 Internet Explorer 的任何实例是否已在运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆