简体   繁体   中英

Windows explorer.exe /select <filepath> doesn't work with new folders

I copy or rename a folder containing some files.

Then, in a command line window I type:

explorer /select,"<full-path-to-a-file-in-new-folder>"

The result is, the folder opens but the file isn't selected. Subsequent calls are fine, this happens only for newly created/renamed folders for the first time ever.

Is this a Windows bug? Is there a way around it?

I just ran into this same problem while trying to use the ShellExecuteEx() to run the Explorer.exe with the /select, to pick a file. Explorer doesn't reliably select the file the first time. Maybe it's a bug... I found a few work arounds for it.

  • Set Explorer to execute as a separate process. This can be done in folder options and selecting "Launch each folder windows in a separate process".
  • Another workaround I found to work is creating a batch file to and launch Explorer from there with explorer.exe /select,"%~1" using the full file name as parameter into the batch file.
  • The last solution is what I ended up doing since I'm writing a program in C++. I used SHOpenFolderAndSelectItems() function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM