Open Folder in Desktop

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kamilche

    #1

    Open Folder in Desktop

    Is there a command you can execute in Python that will open a window on
    the desktop, such as 'My Documents'? Kind of like 'system', but for
    folder names, not just programs. I'm running on Windows 2000.

  • Dennis Benzinger

    #2
    Re: Open Folder in Desktop

    Kamilche wrote:[color=blue]
    > Is there a command you can execute in Python that will open a window on
    > the desktop, such as 'My Documents'? Kind of like 'system', but for
    > folder names, not just programs. I'm running on Windows 2000.
    >[/color]

    Here are some commands you can use (tested on WinXP, so YMMV):


    1. The os.system function

    import os
    os.system('expl orer "c:\program files"')

    This has the disadvantage that a cmd.exe windows is also opened,
    because os.system executes the command in a subshell.

    But using this approach the explorer starts in front of all other windows.


    2. The os.startfile function

    import os
    os.startfile("C :\program files")

    Using startfile doesn't open a cmd.exe window, but the folder window
    is not started in front of the other windows


    3. The subprocess.Pope n function

    import subprocess
    subprocess.Pope n('explorer "C:\program files"')

    With subprocess.Pope n no cmd.exe window is opened and the explorer
    starts in front of the other windows.
    But the subprocess module is new in Python 2.4.



    Bye,
    Dennis

    Comment

    • Ulf Göransson

      #3
      Re: Open Folder in Desktop

      Kamilche wrote:[color=blue]
      > Is there a command you can execute in Python that will open a window on
      > the desktop, such as 'My Documents'? Kind of like 'system', but for
      > folder names, not just programs. I'm running on Windows 2000.[/color]

      Maybe this is good enough?

      os.system("expl orer " + folder_path)

      /ug

      Comment

      • Steve Holden

        #4
        Re: Open Folder in Desktop

        Kamilche wrote:
        [color=blue]
        > Is there a command you can execute in Python that will open a window on
        > the desktop, such as 'My Documents'? Kind of like 'system', but for
        > folder names, not just programs. I'm running on Windows 2000.
        >[/color]
        os.system("star t .")

        works for me.

        regards
        Steve
        --
        Steve Holden http://www.holdenweb.com/
        Python Web Programming http://pydish.holdenweb.com/
        Holden Web LLC +1 703 861 4237 +1 800 494 3119

        Comment

        • Kamilche

          #5
          Re: Open Folder in Desktop

          Thanks, startfile worked great for me!

          Comment

          Working...