Ram Rachum
Ram Rachum

Reputation: 88708

Showing file in Windows Explorer

My favorite IDE Wing IDE has a command for showing the active file in Explorer. This means that when you launch the command, it opens an explorer window on the folder that the file is in, and then selects the file.

The problem is, that if the window is already open, it fails to select the file. It activates the window, but the file doesn't get selected. That's annoying. I want the file to always be selected

I spoke to one of the developers and he said that they're using 'explorer /select,%s' % filename to show the file, and that the above annoyance might be a quirk of that command.

Does anyone have an idea how to avoid this behavior?

(The solution needs to work in Windows 2000, XP, 2003 Server, Vista, and Windows 7.)

Upvotes: 7

Views: 603

Answers (2)

El Zorko
El Zorko

Reputation: 3399

As per https://support.microsoft.com/en-us/kb/152457, which states "switches can be combined", what about:

explorer /n,/select,c:\path\to\file.ext

/n should force a new window.

Upvotes: 2

Anton Semenov
Anton Semenov

Reputation: 6347

I dont know if one exists, but if you create utility which would be implement such solution(C++) it would work as you expected:

void OpenFileInExplorer(LPCTSTR filename)
{
    ITEMIDLIST *pidl = ILCreateFromPath(filename);
    if(pidl) 
    {
        SHOpenFolderAndSelectItems(pidl,0,0,0);
        ILFree(pidl);
    }
}

Upvotes: 0

Related Questions