简体   繁体   English

Windows explorer.exe /选择<filepath>不适用于新文件夹</filepath>

[英]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:然后,在命令行 window 中输入:

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?这是 Windows 错误吗? 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.我在尝试使用ShellExecuteEx()通过 /select 运行 Explorer.exe 来选择文件时遇到了同样的问题。 Explorer doesn't reliably select the file the first time. Explorer 第一次不能可靠地 select 文件。 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".这可以在文件夹选项中完成,并选择“在单独的进程中启动每个文件夹 windows”。
  • 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.我发现另一个可行的解决方法是创建一个批处理文件并使用explorer.exe /select,"%~1"从那里启动资源管理器,使用完整的文件名作为批处理文件的参数。
  • The last solution is what I ended up doing since I'm writing a program in C++. I used SHOpenFolderAndSelectItems() function.最后一个解决方案是我在 C++ 中编写程序后最终所做的。我使用了SHOpenFolderAndSelectItems() function。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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