[wxPython-users] How to open an explorer window?

Chris Mellon arkanes at gmail.com
Thu Aug 2 06:15:41 PDT 2007


On 8/1/07, Phil Mayes <phil at philmayes.com> wrote:
> At 01:41 PM 8/1/2007, Robin Dunn wrote:
> >Phil Mayes wrote:
> >>The only way I could find needed to hardwire the location of explorer :-(
> >
> >You can either count on it being on the PATH, or you can use
> >os.environ['SystemRoot'] to find out the name of the dir it is located in.
>
> Oh, tapping the environment is cool, thanks!  Relying on PATH didn't work
> for me, though:
> os.spawnl(os.P_NOWAIT, 'explorer.exe', ...
> gave me:
> <type 'exceptions.OSError'> [Errno 2] No such file or directory
>
> I switched to Mike Driscoll's suggestion, which didn't need a path:
> subprocess.Popen('explorer /n,/e,/select,"%s"'%utils.GetRootPath())
>
> (My environment: XP not SP2, Python 2.5.1, wx 2.8.4.0)
>
> Phil
>

os.spawn must not use the same win32 apis that subprocess does. I'd
have to dig through MSDN to check but I know there's one that creates
a process from a direct path to an executable image, and another that
uses all the standard path resolution. subprocess is generally to be
preferred over os.spawn and friends for all but the most specialized
of uses, though.




More information about the wxpython-users mailing list