简体   繁体   English

cmd:如果尚未打开,请打开文件夹的资源管理器窗口

[英]cmd: Open explorer window of folder if not already open

This will open MyFolder in Explorer这将在资源管理器中打开 MyFolder

explorer "C:\Users\Username\Desktop\MyFolder"

I'd like it to only do this if it isn't already opened .我希望它尚未打开的情况执行此操作。
Otherwise the the folder gets opened multiple times否则文件夹被打开多次

This is for windows cmd batch这是用于 Windows cmd 批处理

Thanks谢谢

If the path doesn't need quotes:如果路径不需要引号:
start C:\\Users\\Username\\Desktop\\MyFolder

If the path does need quotes:如果路径确实需要引号:
start "" "C:\\program files"

Check the listWindows.bat (unfortunately I think tasklist does not handle the window titles of the explorer.exe windows).检查listWindows.bat (不幸的是,我认为 tasklist 不处理 explorer.exe 窗口的窗口标题)。 It will list all opened windows and the name of the executable they belong to.The windows that are opened by the explorer will have the folder name as a title (only the name - without the whole path) so you can try this:它将列出所有打开的窗口以及它们所属的可执行文件的名称。资源管理器打开的窗口将以文件夹名称作为标题(只有名称 - 没有整个路径),因此您可以尝试以下操作:

call listWindows.bat|find /i "explorer::MyFolder" >nul 2>&1 || (
   explorer "C:\Users\Username\Desktop\MyFolder"
)

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

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