关闭重复打开的文件夹

在平时可能会打开一个文件夹多次,但是不被察觉,因为打开的文件夹太多了,所以需要处理一波。这里还是加到鼠标右键,参考

将CMD添加到鼠标右键_Administrator的博客-CSDN博客

这里是一段vbs代码,可以实现

Set Shell = CreateObject("Shell.Application")
Set Dict = CreateObject("Scripting.Dictionary")
Set Wins = Shell.Windows

For i=Wins.Count-1 To 0 step -1
    If Instr(LCase(Wins(i).FullName),"\explorer.exe") Then
            If Dict.Exists(Wins(i).LocationURL) Then
                    Wins(i).Quit
            Else
                    Dict.Add Wins(i).LocationURL,True
            End If
        End If
Next

然后是一个同级目录下的bat文件,因为vbs文件不是有效的win32执行文件。(双引号里填脚本路径)

@echo off
cd /d ""
关闭重复文件夹.vbs

然后是一个reg文件,注册鼠标右键。

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\CloseDuplicateFolder]
@="关闭重复文件夹"
"Icon"="F:\\Google Downloads\\halashao.ico"

[HKEY_CLASSES_ROOT\Directory\Background\shell\CloseDuplicateFolder\command]
@="F:\\脚本Test\\关闭重复文件夹.bat"

也可以用cscript.exe来运行vbs文件,在注册表值中写入这个。

C:\Windows\System32\cscript.exe /nologo "vbs完整路径"

看效果

《关闭重复打开的文件夹》

 控制台一闪而过,只留下不重复的文件夹,成功。

这里的bat文件和vbs文件要在同级目录下,也可以自己更改,如果有问题可以把文件路径加到环境变量中。

参考

VBS关闭重复的文件夹窗口 – VBS原创&转载 – 批处理之家 批处理_BAT脚本_PowerShell_VBS_CMD_DOS_Perl_Python – Powered by Discuz!

    原文作者:Admini$trat0r
    原文地址: https://blog.csdn.net/qq_41863100/article/details/121928974
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞