Recentemente desenvolvemos uma aplicação que executa uma URL no Elipse E3 Server em um servidor.
Para não deixar múltiplos processos do navegador (no caso Internet Explorer), também desenvolvemos uma forma de terminar o processo aberto anteriormente.
Segue abaixo o código:
<Dados.RunURL:RunURL_onValueChange()>Sub RunURL_onValueChange() 'Executa a URL usando o Internet Explorer IF LEN(Value) > 0 THEN Set WshShell = CreateObject("WScript.Shell") WshShell.Run """C:\Program Files\Internet Explorer\iexplore.exe"" "&Value, 0, false ProcessName = "iexplore.exe" Set service = GetObject("winmgmts:\\.\root\cimv2") Application.TrackEvent "ExecQuery Select * from Win32_Process where Name = " & """" & ProcessName & """" Set results = service.ExecQuery(" Select * from Win32_Process where Name = " & """" & ProcessName & """") if results.count <> 0 then for each obj in results Application.TrackEvent "ProcessId = " & obj.ProcessId Parent.Item("TagInternoProcessID").Value = obj.ProcessId exit for next else Application.TrackEvent "Não foram encontrados processos" end if Value = "" END IF End Sub<Dados.TerminateURL:TerminateURL_OnValueChange()>Sub TerminateURL_OnValueChange() 'Mata processo que foi gerado pelo E3Server 'O E3Viewer pode não ser capaz de localizar o processo por ser usuario diferente IF Parent.Item("TagInternoProcessID").Value > 0 THEN Set service = GetObject("winmgmts:\\.\root\cimv2") Application.TrackEvent "ExecQuery Select * from Win32_Process where ProcessId =" & Parent.Item("TagInternoProcessID").Value Set results = service.ExecQuery(" Select * from Win32_Process where ProcessId =" & Parent.Item("TagInternoProcessID").Value) for each obj in results obj.Terminate() exit for next END IF End SubPara entender melhor o contexto, uma aplicação exemplo pode ser baixada neste link: ExecutaURL rev 3.zip