[Tutor] Python-windows command prompt interaction?
Tim Golden
mail at timgolden.me.uk
Wed Jun 11 10:22:34 CEST 2008
Trey Keown wrote:
> Hey all,
> I'm creating a program that will copy a user's internet history from
> Internet Explorer, and I'm having a bit of trouble.
>
> I need to get python to either initiate a command via the command prompt,
> or open a file with its default program (in this case, a .bat file with
> cmd.exe).
>
> I've been googling a bit, but I can't seem to find any answers.
Depending on *exactly* what you're trying to achieve here, you're
going to want one of two things:
1) The subprocess module (and probably the call function)
http://docs.python.org/lib/node529.html
2) The os module's startfile function
http://docs.python.org/lib/os-process.html
There are other possiblities open to you, including automating
IE and using comtypes to access the IURLHistory interfaces, but
if you're just starting out then maybe you're better off sticking
with the builtin stuff.
TJG
More information about the Tutor
mailing list