os.startfile: Why is there no arguments option?

Christian Wutte christian.wutte at gmx.at
Wed Oct 12 08:18:00 EDT 2011


On Oct 12, 11:27 am, Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-
a470-7603bd3aa... at spamschutz.glglgl.de> wrote:
> Am 12.10.2011 10:22 schrieb Christian Wutte:
>
> > Hello all,
> > as stated in the docs [1] os.startfile relies on Win32 ShellExecute().
> > So maybe someone can explain it to me, why there is no support for
> > program arguments.
>
> Because it is intended to start an arbitrary file of any type (.txt,
> .doc, ...) For this operations, there is no parameter support.
>

Yes, but isn't that also the case for ShellExecute()? In the MSDN page
[1] for the parameters can be read:

"If lpFile specifies an executable file, this parameter is a pointer
to a null-terminated string that specifies the  parameters to be
passed to the application. The format of this string is determined by
the verb that is to be invoked. If lpFile specifies a document file,
lpParameters should be NULL."

So the parameter should be optional for sure.

> > That's quite a pity since os.startfile is the easiest way for an
> > elevated run (with 'runas' as option)
>
> Obviously not.
>
>  > and without arguments of limited use.
>
> So it isn't the asiest way.
>
> Have you tried os.system() and/or subprocess.Popen() resp. .call()?
>

Yes. I should have noticed, that in my case I want to make a manual
elevated call. With programs that need elevated rights in the first
place os.start() or subprocess.Popen(.. , shell=True) is fine.

Chrisitan



More information about the Python-list mailing list