我正在打开Internet Explorer的一个实例,然后尝试关闭该实例。我只有打开网站的代码,没有关闭它。发生的事情是它跳过了应该关闭它的代码,并继续在Internet Explorer中打开新的选项卡。我想先关闭第一个,再打开第二个。这是我到目前为止的代码:
Dim IE As Process = Process.Start("google.com") 'open the website
'close the website
Dim IEProcesses() As Process = System.Diagnostics.Process.GetProcessesByName("IExplorer")
For Each Instance As Process In IEProcesses
If Instance.Handle = IE.Handle Then
Instance.Kill()
End If
Next
MsgBox("The website has been closed")
在论坛上搜索后,我发现了很多类似的问题,但是我似乎无法弄清楚为什么这个问题对我有用。任何帮助将不胜感激!!!
答案 0 :(得分:0)
Internet Explorer进程的名称为<div>
<h2> Nova Conexao</h2>
<input className='uk-input uk-form-width-large' placeholder='Nova conexao' type='text' ref={ref => this.nome = ref} /> <br />
<input className='uk-input uk-form-width-large' placeholder='descricao' type='text' ref={ref => this.descricao = ref} /> <br />
<input className='uk-input uk-form-width-large' placeholder='codigo' type='text' ref={ref => this.codigo = ref} /> <br />
<input className='uk-button uk-button-default' type='file' id='imagem' ref={ref => this.imagem = ref} /> Imagem <br />
<input className='uk-button uk-button-default' type='file' id='imagemTabela' ref={ref => this.imagemTabela = ref} /> Imagem Tabela <br />
<button className='uk-button uk-button-default' type='button' onClick={this.handleSave}>Salvar conexão</button> <br />
</div>
而不是iexplore
(请注意,第一个末尾没有 r 我提到)。
因此您的代码应为:
iexplorer
但是,已经指出(现在已删除的答案)的是,您不需要迭代这样的过程。您需要做的就是在您已有的变量上调用Dim IEProcesses() As Process = System.Diagnostics.Process.GetProcessesByName("iexplore")
:
Kill()
最后,如果您想/需要确保仅通过IE (而不是Chrome或用户作为其默认浏览器的用户)打开URL,则应专门启动它,并通过URL作为参数:
IE.Kill()