Tommy Lawrence
Tommy Lawrence

Reputation: 310

Need help closing a automatically opening internet explorer web page

I have looked extensively through this site and through other sites and modified my code to close my internet explorer page but it will just open and will not close.This is the code.

import webbrowser
import os
webbrowser.open('https://www.youtube.com/watch?v=BByMzI1YjKA')
browserExe = "iexplore"
os.system("taskkill /f /im "+browserExe)

It doesn't give me any error messages but I can't close the browser, any help is much appreciated By the way I'm on windows 10 using python 3.5.1

Upvotes: 0

Views: 305

Answers (1)

Chris Fowl
Chris Fowl

Reputation: 566

The task (internet explorer) doesn't get killed, because the task 'iexplore' doesn't exist. If you open an internet explorer window, it will get the taskname 'iexplore.exe'.

So change this:

browserExe = "iexplore"

to this:

browserExe = "iexplore.exe"

Sincerly, Chris Fowl

Upvotes: 2

Related Questions