Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8838247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:56:33+00:00 2026-06-14T09:56:33+00:00

I want to open Windows Explorer and select a specific file. This is the

  • 0

I want to open Windows Explorer and select a specific file.
This is the API: explorer /select,"PATH". Therefore resulting in the following code (using python 2.7):

import os

PATH = r"G:\testing\189.mp3"
cmd = r'explorer /select,"%s"' % PATH

os.system(cmd)

The code works fine, but when I switch to non-shell mode (with pythonw), a black shell window appears for a moment before the explorer is launched.

This is to be expected with os.system. I’ve created the following function to launch processes without spawning a window:

import subprocess, _subprocess

def launch_without_console(cmd):
    "Function launches a process without spawning a window. Returns subprocess.Popen object."
    suinfo = subprocess.STARTUPINFO()
    suinfo.dwFlags |= _subprocess.STARTF_USESHOWWINDOW
    p = subprocess.Popen(cmd, -1, stdout=subprocess.PIPE, stderr=subprocess.PIPE, startupinfo=suinfo)
    return p

This works fine for shell executables with no GUI. However it won’t launch explorer.exe.

How can I launch the process without spawning a black window before?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T09:56:34+00:00Added an answer on June 14, 2026 at 9:56 am

    It doesn’t seem to be possible. However it can be accessed from the win32api. I’ve used the code found here:

    from win32com.shell import shell
    
    def launch_file_explorer(path, files):
        '''
        Given a absolute base path and names of its children (no path), open
        up one File Explorer window with all the child files selected
        '''
        folder_pidl = shell.SHILCreateFromPath(path,0)[0]
        desktop = shell.SHGetDesktopFolder()
        shell_folder = desktop.BindToObject(folder_pidl, None,shell.IID_IShellFolder)
        name_to_item_mapping = dict([(desktop.GetDisplayNameOf(item, 0), item) for item in shell_folder])
        to_show = []
        for file in files:
            if name_to_item_mapping.has_key(file):
                to_show.append(name_to_item_mapping[file])
            # else:
                # raise Exception('File: "%s" not found in "%s"' % (file, path))
    
        shell.SHOpenFolderAndSelectItems(folder_pidl, to_show, 0)
    launch_file_explorer(r'G:\testing', ['189.mp3'])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to list all open Windows Explorer windows with their active path in
I want to know if there are any methods other than file.open(); in <windows.h>
Guys i am making c# windows application and i want to open any explorer
This code opens a folder if the TotalFileCount == 0. I want to open
When right-clicking a file in Windows Explorer, the Open with menu item displays a
I want to open two (or more) excel windows on different screen (extended displays),
I have 2 windows now that i want to open maximized but should be
In a Windows 8 Metro App I want the ListViewItems/Tiles to open a link
I basically want to open a browser window from Word using VBA that does
I want open a path to vim from Screen's copy-mode by Ctrl-A f similarly

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.