Run Hidden IE session, Terminate after 30 seconds

Hi Everyone,

I’ve been spending the last few days trying to write a script but not having much luck.

What I would like to achieve (whether it be by powershell or some other method) is to open an internet browser window, load a website, wait 30 seconds then terminate the specific window only (Not all active IE windows).

Now I have been able to write a script which kills ALL iexplore.exe windows but haven’t been able to target the specific one.

I did find a lot of useful info on this webpage (Start-Process start - PowerShell - and came up with the following script…

$pclass = [wmiclass]‘root\cimv2:Win32_Process’
$new_pid = $pclass.Create(‘IExplore.exe’, ‘.’, $null).ProcessId
$new_pid = [diagnostics.process]::start(“IExplore.exe”, “”)

Start-Sleep -s 30
kill $new_pid

This opens a iexplore.exe window and loads and after 30 seconds will terminate that iexplore.exe window ONLY. Only thing I need to do now is make it invisible to the end user…

For a little more information what I am trying to achieve is to automatically log a user onto the Office 365 portal when they first login to their machine. This will mean our intranet homepage (hosted on sharepoint) will load faster without the user having to wait for single sign on to login and will mean sharepoint mapped drives will be accessible instantly rather than requiring the end user to open an IE window and login.

I don’t expect anyone to do the work for me, but would be good to know if I am on the right track. I have tried to get this working myself but am under pressure to get it working ASAP.

Cheers, Errol.

Also tried this…

$app = Start-Process -WindowStyle hidden -filepath “C:\Program Files (x86)\Google\Chrome\Application\chrome.exe” -passthru
sleep -s 10
Stop-Process $app.Id

Seems to work for notepad but doesn’t work for IE or chrome…

Try this:

$url = "" 
$ie = New-Object -com internetexplorer.application
$ie.visible = $false