Win10 资源管理器导航栏设置:系统文件夹的显示和隐藏OneDrive,及自定义
如果你和我一样是刚刚从windows7升级到windows10的,我猜你也会发现资源管理器导航栏里略微恼人的变化:库文件不见了,我的电脑里出现了无法隐藏也无法删除的“我的音乐”之类文件(这一个页面里面显示两边也是醉了!),一个懒得使用的Onedrive占据一方。搞掉他!但是好像不是那么简单。花了点时间搜索,我找到了方法。
一、显示库文件
这是最为简单的一条,但是不够细心的我还是在各项设置里面翻了半天才找到。
我的电脑,工具栏,查看(view),导航栏(navigation pane),进入后可以看见如下所示的下拉菜单,点选显示库(show libraries)就可以调出了。果然很简单欸!
二、删除6个文件夹
在我的电脑里,会出现我的音乐、我的文件这样“我的系列”万年文件夹,可是居然好像是无法隐藏的。因为我把所有的材料都保存在其他的盘,这样软件和资料是分开的,既节约系统盘空间(对于固态硬盘更是如此),又方便软件的卸载与资料的迁移等工作,所以这些文件夹于我是没有价值的。这样毫无用处又占据宝地的东西不清理不甘心啊!那怎么办呢?万能网友给出了方案:
(1)本文第一次给出的方案,不完美
1.打开注册表编辑器(在Cortana中输入regedit并回车)
2.定位到HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\
3.右键删除DelegateFolders以上的注册表项
4.重启资源管理器(把所有资源管理器关闭然后再打开我的电脑)后就生效了。
(2)完美且正确的解决方案
本文第一次发布时我就是按照这个方案做的,但是太懒了文章却没有及时更新。近日win10更新后六个文件夹又回来了。于是按照这个完美的方案重新隐藏了它们。注意:是隐藏而不是删除哦!
进入注册表找到一下几个项,想要隐藏什么就选哪个,把注册表里的"ThisPCPolicy"字符串改为Hide,原本是Show。再次打开资源管理器就会发现更改过的图标消失了。
For Pictures folder:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{0ddd015d-b06c-45d5-8c4c-f59713854639}\PropertyBag
For Videos folder:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{35286a68-3c57-41a1-bbb1-0eae73d76c95}\PropertyBag
For Downloads folder:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{7d83ee9b-2244-4e70-b1f5-5393042af1e4}\PropertyBag
For Music folder:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{a0c69a99-21c8-4671-8703-7934162fcf1d}\PropertyBag
For Desktop folder:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}\PropertyBag
For Documents folder:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{f42ee2d3-909f-4907-8871-4c22fc0bf756}\PropertyBag
3D 对象
{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}
还有哦!有时候在第三方软件的打开文件或者保存等这样的窗口下还是会出现这几个图标。具体怎么操作看原作者的内容吧!http://www.askvg.com/tip-remove-6-extra-folders-from-windows-10-explorer-this-pc/
三、隐藏Onedrive
因为国产的网盘应用已经足够了,所以onedrive就没有用处了。但是windows官网说这个应用是built in的,无法卸载,但是可以隐藏。好啊好啊,点击如何隐藏,网页就跳到了莫名其妙的地方了。但是更加万能的外国网友给出了解答。
1. 进入注册表(如上方法)
2. 找到HKEY_CLASSES_ROOT\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6},将System.IsPinnedToNameSpaceTree的值改为0。
3. 如果是64位系统,把HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6中System.IsPinnedToNameSpaceTree的值改为0。
4. 都不需要重启资源管理器,onedrive就消失了。
于是简单方便三级导航又回来了。近期密度最高的pin在quick access里,各个盘在this pc里,各类资料库直接可以进入。
出处:https://www.jianshu.com/p/a13f63073d53
=======================================================================================
使用This PC Tweaker软件设置
首先下载该软件:网盘链接
打开软件之后点击设置,设置为中文,设置之后重启软件
点击添加自定义文件,
选择要添加的文件夹,
指定文件夹名称之后确定。
选择是否显示在此电脑,还是显示在导航窗口
更改图标
大功告成
望采纳~
出处:https://zhidao.baidu.com/question/2120018825130775027.html
=======================================================================================
资源管理器左侧导航栏扩展自定义文件夹
-
缘起
最近在重新归档文件,切换文件夹跳来跳去的很麻烦(windows11任务栏都缩成小图标,也不能像以前那样快捷点击),所以研究下资源管理器左侧导航栏扩展,虽然也并没有方便的多少- -。 -
过程
- 由于电脑终安装了
坚果云
,所以很快就定位到相关注册表,其中System.IsPinnedToNameSpaceTree
注册表项引起了关注,通过搜索,定位到微软相关文档,虽然是针对云存储扩展的 - Integrate a Cloud Storage Provider:https://docs.microsoft.com/en-us/windows/win32/shell/integrate-cloud-storage
- 由于电脑终安装了
-
脚本(复制脚本,存储为
.cmd
批处理文件,修改关键的三个变量,执行即可,有需求的也可自行改为传参方式、扩展for循环、甚至界面工具)chcp 65001 rem 首先,通过下面的命令,手动生成几个uuid,比如笔者生成了5个 rem 当然,这里只是要生产uuid,并不限制工具,大小写可能也不限制,只是保持跟windows风格一致 rem uuidgen.exe的路径可能跟笔者的不一样,可以换成自己电脑上的路径 rem 生成一批uuid,-h帮助,-c大写,-n5生成5个 rem "C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\uuidgen.exe" -c -n5 rem 生成的uuid这里做个备份,习惯而已(下面展示的随机的并不是真正的id) rem XXXXXXX1-XXXX-XXXX-XXXX-XXXXXXXXXXXX rem XXXXXXX2-XXXX-XXXX-XXXX-XXXXXXXXXXXX rem XXXXXXX3-XXXX-XXXX-XXXX-XXXXXXXXXXXX rem XXXXXXX4-XXXX-XXXX-XXXX-XXXXXXXXXXXX rem XXXXXXX5-XXXX-XXXX-XXXX-XXXXXXXXXXXX rem 设置3个变量 set custom_clsid=XXXXXXX1-XXXX-XXXX-XXXX-XXXXXXXXXXXX set custom_show_name=documents set custom_directory=C:\WorkSpace\documents rem 下面的命令就不用改了 rem Step 1: Add your CLSID and name your extension reg add HKCU\Software\Classes\CLSID\{%custom_clsid%} /ve /t REG_SZ /d %custom_show_name% /f rem Step 2: Set the image for your icon reg add HKCU\Software\Classes\CLSID\{%custom_clsid%}\DefaultIcon /ve /t REG_EXPAND_SZ /d %%SystemRoot%%\system32\imageres.dll,-1043 /f rem Step 3: Add your extension to the Navigation Pane and make it visible reg add HKCU\Software\Classes\CLSID\{%custom_clsid%} /v System.IsPinnedToNameSpaceTree /t REG_DWORD /d 0x1 /f rem Step 4: Set the location for your extension in the Navigation Pane reg add HKCU\Software\Classes\CLSID\{%custom_clsid%} /v SortOrderIndex /t REG_DWORD /d 0x42 /f rem Step 5: Provide the dll that hosts your extension reg add HKCU\Software\Classes\CLSID\{%custom_clsid%}\InProcServer32 /ve /t REG_EXPAND_SZ /d %%systemroot%%\system32\shell32.dll /f rem Step 6: Define the instance object reg add HKCU\Software\Classes\CLSID\{%custom_clsid%}\Instance /v CLSID /t REG_SZ /d {0E5AAE11-A475-4c5b-AB00-C66DE400274E} /f rem Step 7: Provide the file system attributes of the target folder reg add HKCU\Software\Classes\CLSID\{%custom_clsid%}\Instance\InitPropertyBag /v Attributes /t REG_DWORD /d 0x11 /f rem Step 8: Set the path for the sync root reg add HKCU\Software\Classes\CLSID\{%custom_clsid%}\Instance\InitPropertyBag /v TargetFolderPath /t REG_EXPAND_SZ /d %custom_directory% /f rem Step 9: Set appropriate shell flags reg add HKCU\Software\Classes\CLSID\{%custom_clsid%}\ShellFolder /v FolderValueFlags /t REG_DWORD /d 0x28 /f rem Step 10: Set the appropriate flags to control your shell behavior reg add HKCU\Software\Classes\CLSID\{%custom_clsid%}\ShellFolder /v Attributes /t REG_DWORD /d 0xF080004D /f rem Step 11: Register your extension in the namespace root(关键命令:显示到左侧导航栏) reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{%custom_clsid%} /ve /t REG_SZ /d %custom_show_name% /f rem Step 12: Hide your extension from the Desktop(关键命令:隐藏桌面上多出的图标) reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel /v {%custom_clsid%} /t REG_DWORD /d 0x1 /f
-
脚本解释
-
step 11:显示到左侧栏
-
step 12:隐藏桌面上多出的图标(如果不隐藏,桌面上就会多出刚创建的文件夹。当然,不隐藏也有妙用,至少没有快捷方式那个箭头)
-
-
优点分析
- 可以方便的进入一些常用文件夹(桌面快捷方式的别搅局)
- 对于
另存为
等操作也会方便很多,可以直接进入文件夹,不需要一层层点进去了
-
不足分析
- 默认的图标没改,都显示的云图标(大概由于该功能本来就是给云盘扩展用的吧),也可以自己改,有需求的自己修改
step 2
- 从导航栏进入文件夹,路径栏显示的不是绝对路径,对于拷贝路径来讲并不方便,当然,这并不影响从盘符一层层进入目录
- 默认的图标没改,都显示的云图标(大概由于该功能本来就是给云盘扩展用的吧),也可以自己改,有需求的自己修改
出处:https://blog.csdn.net/toothing/article/details/124650049
=======================================================================================
个人使用--自定义导航栏
计划:根据This PC Tweaker软件的设置注册表,以及结合上面的批处理代码,我们也自己改一改,可以适合自己使用的脚本。
版本1
根据上面的bat脚本修改,使用固定guid,后续改成自动生成的,把下面的代码保存为naviBar.bat文件
@ECHO OFF&PUSHD %~DP0 &TITLE windows自动替换脚本-百度子成君 mode con lines=30 cols=60 ::%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit cd /d "%~dp0" cls :main echo. echo.----------------------------------------------------------- rem 设置3个变量 022d3403-ac03-4117-93be-98dd0e59a4cd ::set custom_clsid=XXXXXXX1-XXXX-XXXX-XXXX-XXXXXXXXXXXX set custom_clsid=00000000-1111-2222-3333-000000000002 set custom_show_name=myDoc2 set custom_directory=C:\WorkSpace\documents echo 导航名称:%custom_show_name% echo 导航路径:%custom_directory% echo. echo.----------------------------------------------------------- echo.如有360、电脑管家等安全软件提醒,请勾选信任允许和不再提醒! echo. echo.请选择使用:(请以管理员身份运行此脚本,否则可能不成功) echo. echo. 1.添加注册表,请输入1 echo. 2.删除注册表,请输入2 echo.----------------------------------------------------------- if exist "%SystemRoot%\System32\choice.exe" goto Win7Choice set /p choice=请输入数字并按回车键确认: echo. if %choice%==1 goto addFun if %choice%==2 goto delFun "set choice=" echo 您输入有误,请重新选择。 ping 127.0.1 -n 1>nul goto main :Win7Choice echo ==Win7Choice== choice /c 12 /n /m "请输入相应数字:" if %errorlevel%==1 goto addFun if %errorlevel%==2 goto delFun goto main :addFun echo. echo 即将添加注册表 & pause rem 下面的命令就不用改了 rem Step 1: Add your CLSID and name your extension reg add HKCU\Software\Classes\CLSID\{%custom_clsid%} /ve /t REG_SZ /d %custom_show_name% /f rem Step 2: Set the image for your icon reg add HKCU\Software\Classes\CLSID\{%custom_clsid%}\DefaultIcon /ve /t REG_EXPAND_SZ /d %%SystemRoot%%\system32\shell32.dll,3 /f rem Step 3: Add your extension to the Navigation Pane and make it visible reg add HKCU\Software\Classes\CLSID\{%custom_clsid%} /v System.IsPinnedToNameSpaceTree /t REG_DWORD /d 0x1 /f rem Step 4: Set the location for your extension in the Navigation Pane reg add HKCU\Software\Classes\CLSID\{%custom_clsid%} /v SortOrderIndex /t REG_DWORD /d 0x42 /f rem Step 5: Provide the dll that hosts your extension reg add HKCU\Software\Classes\CLSID\{%custom_clsid%}\InProcServer32 /ve /t REG_EXPAND_SZ /d %%systemroot%%\system32\shell32.dll /f rem Step 6: Define the instance object reg add HKCU\Software\Classes\CLSID\{%custom_clsid%}\Instance /v CLSID /t REG_SZ /d {0E5AAE11-A475-4c5b-AB00-C66DE400274E} /f rem Step 7: Provide the file system attributes of the target folder reg add HKCU\Software\Classes\CLSID\{%custom_clsid%}\Instance\InitPropertyBag /v Attributes /t REG_DWORD /d 0x11 /f rem Step 8: Set the path for the sync root reg add HKCU\Software\Classes\CLSID\{%custom_clsid%}\Instance\InitPropertyBag /v TargetFolderPath /t REG_EXPAND_SZ /d %custom_directory% /f rem Step 9: Set appropriate shell flags reg add HKCU\Software\Classes\CLSID\{%custom_clsid%}\ShellFolder /v FolderValueFlags /t REG_DWORD /d 0x28 /f rem Step 10: Set the appropriate flags to control your shell behavior reg add HKCU\Software\Classes\CLSID\{%custom_clsid%}\ShellFolder /v Attributes /t REG_DWORD /d 0xF080004D /f rem Step 11: Register your extension in the namespace root(关键命令:显示到左侧导航栏) reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{%custom_clsid%} /ve /t REG_SZ /d %custom_show_name% /f ::reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{%custom_clsid%} /ve /t REG_SZ /d %custom_show_name% /f rem Step 12: Hide your extension from the Desktop(关键命令:隐藏桌面上多出的图标) reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel /v {%custom_clsid%} /t REG_DWORD /d 0x1 /f echo. echo 注册表已添加{%custom_clsid%} echo.----------------------------------------------------------- goto end :delFun echo 即将删除注册表 & pause rem REG Delete HKEY_CLASSES_ROOT\Directory\Background\shell\测试 /f reg delete HKCU\Software\Classes\CLSID\{%custom_clsid%} /f reg delete HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{%custom_clsid%} /f reg delete HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel /v {%custom_clsid%} /f echo. echo 注册表已删除{%custom_clsid%} echo.----------------------------------------------------------- goto end :end echo 请按任意键退出。 @Pause>nul
版本2
结合This PC Tweaker软件和上面的bat,并增加了myName标识,方便后续自动删除的时候进行识别
@ECHO OFF&PUSHD %~DP0 &TITLE windows自动替换脚本-Jack_孟 ::mode con lines=30 cols=60 ::%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit cd /d "%~dp0" :main echo. echo.----------------------------------------------------------- rem 设置3个变量 022d3403-ac03-4117-93be-98dd0e59a4cd ::set custom_clsid=XXXXXXX1-XXXX-XXXX-XXXX-XXXXXXXXXXXX set custom_clsid=00000000-1111-2222-3333-000000000002 set custom_show_name=myDoc2 set custom_directory=C:\WorkSpace\documents echo 导航名称:%custom_show_name% echo 导航路径:%custom_directory% echo. echo.----------------------------------------------------------- echo.如有360、电脑管家等安全软件提醒,请勾选信任允许和不再提醒! echo. echo.请选择使用:(请以管理员身份运行此脚本,否则可能不成功) echo. echo. 1.添加注册表,请输入1 echo. 2.删除注册表,请输入2 echo.----------------------------------------------------------- if exist "%SystemRoot%\System32\choice.exe" goto Win7Choice set /p choice=请输入数字并按回车键确认: echo. if %choice%==1 goto addFun if %choice%==2 goto delFun "set choice=" echo 您输入有误,请重新选择。 ping 127.0.1 -n 1>nul goto main :Win7Choice echo ==Win7Choice== choice /c 12 /n /m "请输入相应数字:" if %errorlevel%==1 goto addFun if %errorlevel%==2 goto delFun goto main :addFun echo. FOR /F %%a IN ('POWERSHELL -COMMAND "$([guid]::NewGuid().ToString())"') DO (SET custom_clsid=%%a) echo 即将添加注册表:{%custom_clsid%} & pause rem 下面的命令就不用改了 rem Step 1: Add your CLSID and name your extension reg add HKCU\Software\Classes\CLSID\{%custom_clsid%} /ve /t REG_SZ /d %custom_show_name% /f rem Step 2: Set the image for your icon reg add HKCU\Software\Classes\CLSID\{%custom_clsid%}\DefaultIcon /ve /t REG_EXPAND_SZ /d %%SystemRoot%%\system32\shell32.dll,3 /f rem Step 3: Add your extension to the Navigation Pane and make it visible reg add HKCU\Software\Classes\CLSID\{%custom_clsid%} /v System.IsPinnedToNameSpaceTree /t REG_DWORD /d 0x1 /f rem Step 4: Set the location for your extension in the Navigation Pane reg add HKCU\Software\Classes\CLSID\{%custom_clsid%} /v SortOrderIndex /t REG_DWORD /d 0x42 /f reg add HKCU\Software\Classes\CLSID\{%custom_clsid%} /v myName /t REG_SZ /d customNavigator /f rem Step 5: Provide the dll that hosts your extension(可以把shdocvw.dll替换shell32.dll) reg add HKCU\Software\Classes\CLSID\{%custom_clsid%}\InProcServer32 /ve /t REG_EXPAND_SZ /d %%systemroot%%\system32\shdocvw.dll /f reg add HKCU\Software\Classes\CLSID\{%custom_clsid%}\InProcServer32 /v ThreadingModel /t REG_SZ /d Both /f rem Step 6: Define the instance object reg add HKCU\Software\Classes\CLSID\{%custom_clsid%}\Instance /v CLSID /t REG_SZ /d {0afaced1-e828-11d1-9187-b532f1e9575d} /f rem Step 7: Provide the file system attributes of the target folder reg add HKCU\Software\Classes\CLSID\{%custom_clsid%}\Instance\InitPropertyBag /v Attributes /t REG_DWORD /d 0x11 /f rem Step 8: Set the path for the sync root(有的系统使用的是TargetFolderPath,有的是Target) ::reg add HKCU\Software\Classes\CLSID\{%custom_clsid%}\Instance\InitPropertyBag /v TargetFolderPath /t REG_EXPAND_SZ /d %custom_directory% /f reg add HKCU\Software\Classes\CLSID\{%custom_clsid%}\Instance\InitPropertyBag /v Target /t REG_EXPAND_SZ /d %custom_directory% /f rem Set the sort of the target's attribute tabs (4个属性选项卡可以不添加) reg add "HKCU\Software\Classes\CLSID\{%custom_clsid%}\ShellEx\PropertySheetHandlers\tab 1 general" /ve /t REG_SZ /d {21b22460-3aea-1069-a2dc-08002b30309d} /f reg add "HKCU\Software\Classes\CLSID\{%custom_clsid%}\ShellEx\PropertySheetHandlers\tab 2 customize" /ve /t REG_SZ /d {ef43ecfe-2ab9-4632-bf21-58909dd177f0} /f reg add "HKCU\Software\Classes\CLSID\{%custom_clsid%}\ShellEx\PropertySheetHandlers\tab 3 sharing" /ve /t REG_SZ /d {f81e9010-6ea4-11ce-a7ff-00aa003ca9f6} /f reg add "HKCU\Software\Classes\CLSID\{%custom_clsid%}\ShellEx\PropertySheetHandlers\tab 4 security" /ve /t REG_SZ /d {1f2e5c40-9550-11ce-99d2-00aa006e086c} /f rem Step 9: Set appropriate shell flags reg add HKCU\Software\Classes\CLSID\{%custom_clsid%}\ShellFolder /v FolderValueFlags /t REG_DWORD /d 0x28 /f rem Step 10: Set the appropriate flags to control your shell behavior reg add HKCU\Software\Classes\CLSID\{%custom_clsid%}\ShellFolder /v Attributes /t REG_DWORD /d 0xF080004D /f reg add HKCU\Software\Classes\CLSID\{%custom_clsid%}\ShellFolder /v HideAsDeletePerUser /t REG_SZ /f reg add HKCU\Software\Classes\CLSID\{%custom_clsid%}\ShellFolder /v WantsFORPARSING /t REG_SZ /f rem Step 11: Register your extension in the namespace root(关键命令:显示到左侧导航栏根节点下面) reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{%custom_clsid%} /ve /t REG_SZ /d %custom_show_name% /f rem (关键命令:显示到左侧导航栏我的电脑节点下面) ::reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{%custom_clsid%} /ve /t REG_SZ /d %custom_show_name% /f rem Step 12: Hide your extension from the Desktop(关键命令:如果注册在导航栏根节点下,则需要隐藏桌面上多出的图标) reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel /v {%custom_clsid%} /t REG_DWORD /d 0x1 /f echo. echo 注册表已添加{%custom_clsid%} echo.----------------------------------------------------------- goto endFun :delFun echo. set /p custom_clsid=请输入GUID并确认: echo 即将删除注册表:{%custom_clsid%} & pause rem REG Delete HKEY_CLASSES_ROOT\Directory\Background\shell\测试 /f reg delete HKCU\Software\Classes\CLSID\{%custom_clsid%} /f reg delete HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{%custom_clsid%} /f reg delete HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel /v {%custom_clsid%} /f echo. echo 注册表已删除{%custom_clsid%} echo.----------------------------------------------------------- goto endFun :endFun echo 请按任意键退出。 ::@Pause>nul
后续优化:自动遍历注册表,查找需要删除的guid,使用选择的方式,根据GUID删除指定注册表
版本3
使用交互式模式,增加安全确认的选择。
添加:用户指定目标目录,自动添加对应注册表。
删除:自动搜索注册表中已注册的导航菜单,根据用户选择需要删除指定对象
@ECHO Off&PUSHD "%~DP0"&TITLE windows自动替换脚本-Jack_孟 Setlocal enabledelayedexpansion ::mode con lines=30 cols=60 ::%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit :main echo. echo.----------------------------------------------------------- rem 设置3个变量 022d3403-ac03-4117-93be-98dd0e59a4cd ::set custom_clsid={XXXXXXX1-XXXX-XXXX-XXXX-XXXXXXXXXXXX} set custom_clsid={00000000-1111-2222-3333-000000000002} set custom_show_name=myDoc2 set custom_directory=C:\WorkSpace\documents set clsidPath=HKCU\Software\Classes\CLSID echo 导航名称:%custom_show_name% echo 导航路径:%custom_directory% echo. set isRun= echo.----------------------------------------------------------- echo.如有360、电脑管家等安全软件提醒,请勾选信任允许和不再提醒! echo. echo.请选择使用:(请以管理员身份运行此脚本,否则可能不成功) echo. echo. 1.添加注册表,请输入1 echo. 2.删除注册表,请输入2 echo.----------------------------------------------------------- if exist "%SystemRoot%\System32\choice.exe" goto Win7Choice set /p choice=请输入数字并按回车键确认: echo. if %choice%==1 goto addFun if %choice%==2 goto delFun "set choice=" echo 您输入有误,请重新选择。 ping 127.0.1 -n 1>nul goto main :Win7Choice echo ==Win7Choice== choice /c 12 /n /m "请输入相应数字:" if %errorlevel%==1 goto addFun if %errorlevel%==2 goto delFun goto main :addFun echo. set isFile=1 set /p folderPath=请输入导航路径: if "%folderPath%"=="" echo.&echo.===[WAN:你未输入任何需要导航的路径]===&goto endFun set custom_directory=%folderPath:"=% pushd %custom_directory% 2>nul&&(popd&set isFile=0) if %isFile%==1 ((for /f "delims=\" %%i in ("%custom_directory%") do set custom_show_name=%%~ni)&(for %%a in ("%custom_directory%") do set custom_directory=%%~dpa)) else (for %%a in ("%custom_directory%") do set custom_show_name=%%~na) if "%custom_directory:~-1%"=="\" set custom_directory=%custom_directory:~0,-1% FOR /F %%a IN ('POWERSHELL -COMMAND "$([guid]::NewGuid().ToString())"') DO (SET custom_clsid={%%a}) set custom_clsid={00000000%custom_clsid:~9% echo.----------------------------------------------------------- echo.&echo 即将添加注册表:&echo %custom_clsid%【%custom_show_name%】【"%custom_directory%"】 echo.&echo 继续执行请按Y键,终止执行请关闭窗口!&set /p isRun=是否继续执行?[Y/N]: if /i not "%isRun%"=="Y" echo.&echo.===[WAN:终止添加注册表项]===&goto endFun ::goto endFun rem 下面的命令就不用改了 rem Step 1: Add your CLSID and name your extension reg add HKCU\Software\Classes\CLSID\%custom_clsid% /ve /t REG_SZ /d %custom_show_name% /f rem Step 2: Set the image for your icon reg add HKCU\Software\Classes\CLSID\%custom_clsid%\DefaultIcon /ve /t REG_EXPAND_SZ /d %%SystemRoot%%\system32\shell32.dll,3 /f rem Step 3: Add your extension to the Navigation Pane and make it visible reg add HKCU\Software\Classes\CLSID\%custom_clsid% /v System.IsPinnedToNameSpaceTree /t REG_DWORD /d 0x1 /f rem Step 4: Set the location for your extension in the Navigation Pane reg add HKCU\Software\Classes\CLSID\%custom_clsid% /v SortOrderIndex /t REG_DWORD /d 0x42 /f reg add HKCU\Software\Classes\CLSID\%custom_clsid% /v myName /t REG_SZ /d customNavigator /f rem Step 5: Provide the dll that hosts your extension(可以把shdocvw.dll替换shell32.dll) reg add HKCU\Software\Classes\CLSID\%custom_clsid%\InProcServer32 /ve /t REG_EXPAND_SZ /d %%systemroot%%\system32\shdocvw.dll /f reg add HKCU\Software\Classes\CLSID\%custom_clsid%\InProcServer32 /v ThreadingModel /t REG_SZ /d Both /f rem Step 6: Define the instance object reg add HKCU\Software\Classes\CLSID\%custom_clsid%\Instance /v CLSID /t REG_SZ /d {0afaced1-e828-11d1-9187-b532f1e9575d} /f rem Step 7: Provide the file system attributes of the target folder reg add HKCU\Software\Classes\CLSID\%custom_clsid%\Instance\InitPropertyBag /v Attributes /t REG_DWORD /d 0x11 /f rem Step 8: Set the path for the sync root(有的系统使用的是TargetFolderPath,有的是Target) ::reg add HKCU\Software\Classes\CLSID\%custom_clsid%\Instance\InitPropertyBag /v TargetFolderPath /t REG_EXPAND_SZ /d %custom_directory% /f reg add HKCU\Software\Classes\CLSID\%custom_clsid%\Instance\InitPropertyBag /v Target /t REG_EXPAND_SZ /d "%custom_directory%" /f rem Set the sort of the target's attribute tabs (4个属性选项卡可以不添加) reg add "HKCU\Software\Classes\CLSID\%custom_clsid%\ShellEx\PropertySheetHandlers\tab 1 general" /ve /t REG_SZ /d {21b22460-3aea-1069-a2dc-08002b30309d} /f reg add "HKCU\Software\Classes\CLSID\%custom_clsid%\ShellEx\PropertySheetHandlers\tab 2 customize" /ve /t REG_SZ /d {ef43ecfe-2ab9-4632-bf21-58909dd177f0} /f reg add "HKCU\Software\Classes\CLSID\%custom_clsid%\ShellEx\PropertySheetHandlers\tab 3 sharing" /ve /t REG_SZ /d {f81e9010-6ea4-11ce-a7ff-00aa003ca9f6} /f reg add "HKCU\Software\Classes\CLSID\%custom_clsid%\ShellEx\PropertySheetHandlers\tab 4 security" /ve /t REG_SZ /d {1f2e5c40-9550-11ce-99d2-00aa006e086c} /f rem Step 9: Set appropriate shell flags reg add HKCU\Software\Classes\CLSID\%custom_clsid%\ShellFolder /v FolderValueFlags /t REG_DWORD /d 0x28 /f rem Step 10: Set the appropriate flags to control your shell behavior reg add HKCU\Software\Classes\CLSID\%custom_clsid%\ShellFolder /v Attributes /t REG_DWORD /d 0xF080004D /f reg add HKCU\Software\Classes\CLSID\%custom_clsid%\ShellFolder /v HideAsDeletePerUser /t REG_SZ /f reg add HKCU\Software\Classes\CLSID\%custom_clsid%\ShellFolder /v WantsFORPARSING /t REG_SZ /f rem Step 11: Register your extension in the namespace root(关键命令:显示到左侧导航栏根节点下面) reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\%custom_clsid% /ve /t REG_SZ /d %custom_show_name% /f rem (关键命令:显示到左侧导航栏我的电脑节点下面) ::reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\%custom_clsid% /ve /t REG_SZ /d %custom_show_name% /f rem Step 12: Hide your extension from the Desktop(关键命令:如果注册在导航栏根节点下,则需要隐藏桌面上多出的图标) reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel /v %custom_clsid% /t REG_DWORD /d 0x1 /f echo.&echo 已添加注册表:&echo %custom_clsid%【%custom_show_name%】【"%custom_directory%"】 echo.----------------------------------------------------------- goto endFun :delFun rem 先遍历注册表项,再选择删除指定clsid echo.&echo 开始查找注册表......&echo. set /A regPathCount=1 FOR /L %%i IN (0,1,9) DO set obj_%%i_clsid=&set obj_%%i_foldName=&set obj_%%i_foldPath= ::for /f "tokens=1-4,* delims=\" %%a in ('reg query "%clsidPath%"') do (for /f "tokens=1,2,*" %%i in ('reg query "%%a\%%b\%%c\%%d\%%e" /v "myName"') do (if not "%%i"=="%%a\%%b\%%c\%%d\%%e" set /A regPathCount+=1&set _clsid=!_clsid!%%e )) for /f "tokens=1-4,* delims=\" %%a in ('reg query "%clsidPath%"') do (for /f "tokens=1,2,*" %%i in ('reg query "%%a\%%b\%%c\%%d\%%e" /v "myName" 2^>NUL') do (if not "%%i"=="%%a\%%b\%%c\%%d\%%e" set obj_!regPathCount!_clsid=%%e&set /A regPathCount+=1)) set /A regPathCount-=1 if "%regPathCount%"=="0" echo.&echo.===[WAN:未找到需要删除的注册表项]===&goto endFun set custom_clsid=&set custom_show_name=&set custom_directory= echo 查找到以下注册表项: IF %regPathCount% GTR 1 ( FOR /L %%i IN (1,1,%regPathCount%) DO ( rem read reg default value for /f "tokens=1-3,*" %%a in ('reg query "%clsidPath%\!obj_%%i_clsid!" /ve 2^>NUL') do (if not "%%a"=="%clsidPath%\!obj_%%i_clsid!" set obj_%%i_foldName=%%c) rem read reg folder path value for /f "tokens=1,2,*" %%a in ('reg query "%clsidPath%\!obj_%%i_clsid!\Instance\InitPropertyBag" /v "Target" 2^>NUL') do (if not "%%a"=="%clsidPath%\!obj_%%i_clsid!" set obj_%%i_foldPath=%%c) echo %%i:!obj_%%i_clsid!【!obj_%%i_foldName!】【"!obj_%%i_foldPath!"】 ) echo.&set /p regPathIndex=请选择要删除的注册表序号: FOR /L %%i IN (1,1,%regPathCount%) DO (if %%i==!regPathIndex! set custom_clsid=!obj_%%i_clsid!&set custom_show_name=!obj_%%i_foldName!&set custom_directory=!obj_%%i_foldPath!) ) ELSE ( rem read reg default value for /f "tokens=1-3,*" %%a in ('reg query "%clsidPath%\!obj_%regPathCount%_clsid!" /ve 2^>NUL') do (if not "%%a"=="%clsidPath%\!obj_%regPathCount%_clsid!" set obj_%regPathCount%_foldName=%%c) rem read reg folder path value for /f "tokens=1,2,*" %%a in ('reg query "%clsidPath%\!obj_%regPathCount%_clsid!\Instance\InitPropertyBag" /v "Target" 2^>NUL') do (if not "%%a"=="%clsidPath%\!obj_%regPathCount%_clsid!" set obj_%regPathCount%_foldPath=%%c) set custom_clsid=!obj_%regPathCount%_clsid!&set custom_show_name=!obj_%regPathCount%_foldName!&set custom_directory=!obj_%regPathCount%_foldPath! echo %regPathCount%:!obj_%regPathCount%_clsid!【!obj_%regPathCount%_foldName!】【"!obj_%regPathCount%_foldPath!"】) if "%custom_clsid%"=="" echo.&echo.===[WAN:未指定注册表项]===&goto endFun echo.----------------------------------------------------------- echo 即将删除注册表:&echo %custom_clsid%【%custom_show_name%】【"%custom_directory%"】 echo.&echo 继续执行请按Y键,终止执行请关闭窗口!&set /p isRun=是否继续执行?[Y/N]: if /i not "%isRun%"=="Y" echo.&echo.===[WAN:终止删除注册表项]===&goto endFun reg delete HKCU\Software\Classes\CLSID\%custom_clsid% /f reg delete HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\%custom_clsid% /f reg delete HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel /v %custom_clsid% /f echo.&echo 已删除注册表:&echo %custom_clsid%【%custom_show_name%】【"%custom_directory%"】 echo.----------------------------------------------------------- goto endFun :endFun echo.&echo 请按任意键退出。&echo. Pause>nul
版本4
增加日志记录
@ECHO Off&PUSHD "%~DP0"&TITLE windows自动替换脚本-Jack_孟 Setlocal enabledelayedexpansion ::mode con lines=30 cols=60 ::%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit :main echo. set logFile="%~d0\%~nx0_log.txt" echo.----------------------------------------------------------->>%logFile% echo.----------------------------------------------------------- rem 设置3个变量 022d3403-ac03-4117-93be-98dd0e59a4cd ::set custom_clsid={XXXXXXX1-XXXX-XXXX-XXXX-XXXXXXXXXXXX} set custom_clsid={00000000-1111-2222-3333-000000000002} set custom_show_name=myDoc2 set custom_directory=C:\WorkSpace\documents set clsidPath=HKCU\Software\Classes\CLSID echo [%date% %time%] 本文件由 %0 程序写入>>%logFile% echo [%date% %time%] 本文件由 %0 程序写入:%logFile% set isRun= echo. echo.----------------------------------------------------------- echo.如有360、电脑管家等安全软件提醒,请勾选信任允许和不再提醒! echo. echo.请选择使用:(请以管理员身份运行此脚本,否则可能不成功) echo. echo. 1.添加注册表,请输入1 echo. 2.删除注册表,请输入2 echo.----------------------------------------------------------- if exist "%SystemRoot%\System32\choice.exe" goto Win7Choice set /p choice=请输入数字并按回车键确认: echo. if %choice%==1 goto addFun if %choice%==2 goto delFun "set choice=" echo 您输入有误,请重新选择。 ping 127.0.1 -n 1>nul goto main :Win7Choice echo ==Win7Choice== choice /c 12 /n /m "请输入相应数字:" if %errorlevel%==1 goto addFun if %errorlevel%==2 goto delFun goto main :addFun echo;&echo [%date% %time%] 用户正在添加注册表>>%logFile% echo;&echo [%date% %time%] 用户正在添加注册表 echo. set isFile=1 set /p folderPath=请输入导航路径: if "%folderPath%"=="" echo.&echo.===[WAN:你未输入任何需要导航的路径]===&goto endFun set custom_directory=%folderPath:"=% pushd %custom_directory% 2>nul&&(popd&set isFile=0) if %isFile%==1 ((for /f "delims=\" %%i in ("%custom_directory%") do set custom_show_name=%%~ni)&(for %%a in ("%custom_directory%") do set custom_directory=%%~dpa)) else (for %%a in ("%custom_directory%") do set custom_show_name=%%~na) if "%custom_directory:~-1%"=="\" set custom_directory=%custom_directory:~0,-1% FOR /F %%a IN ('POWERSHELL -COMMAND "$([guid]::NewGuid().ToString())"') DO (SET custom_clsid={%%a}) set custom_clsid={00000000%custom_clsid:~9% echo.----------------------------------------------------------- echo.&echo 即将添加注册表:>>%logFile% echo.&echo 即将添加注册表: echo %custom_clsid%【%custom_show_name%】【"%custom_directory%"】>>%logFile% echo %custom_clsid%【%custom_show_name%】【"%custom_directory%"】 echo.&echo 继续执行请按Y键,终止执行请关闭窗口!&set /p isRun=是否继续执行?[Y/N]: if /i not "%isRun%"=="Y" (echo.===[WAN:终止添加注册表项]===>>%logFile%&echo.===[WAN:终止添加注册表项]===&goto endFun) ::goto endFun rem 下面的命令就不用改了 rem Step 1: Add your CLSID and name your extension reg add HKCU\Software\Classes\CLSID\%custom_clsid% /ve /t REG_SZ /d %custom_show_name% /f rem Step 2: Set the image for your icon reg add HKCU\Software\Classes\CLSID\%custom_clsid%\DefaultIcon /ve /t REG_EXPAND_SZ /d %%SystemRoot%%\system32\shell32.dll,3 /f rem Step 3: Add your extension to the Navigation Pane and make it visible reg add HKCU\Software\Classes\CLSID\%custom_clsid% /v System.IsPinnedToNameSpaceTree /t REG_DWORD /d 0x1 /f rem Step 4: Set the location for your extension in the Navigation Pane reg add HKCU\Software\Classes\CLSID\%custom_clsid% /v SortOrderIndex /t REG_DWORD /d 0x42 /f reg add HKCU\Software\Classes\CLSID\%custom_clsid% /v myName /t REG_SZ /d customNavigator /f rem Step 5: Provide the dll that hosts your extension(可以把shdocvw.dll替换shell32.dll) reg add HKCU\Software\Classes\CLSID\%custom_clsid%\InProcServer32 /ve /t REG_EXPAND_SZ /d %%systemroot%%\system32\shdocvw.dll /f reg add HKCU\Software\Classes\CLSID\%custom_clsid%\InProcServer32 /v ThreadingModel /t REG_SZ /d Both /f rem Step 6: Define the instance object reg add HKCU\Software\Classes\CLSID\%custom_clsid%\Instance /v CLSID /t REG_SZ /d {0afaced1-e828-11d1-9187-b532f1e9575d} /f rem Step 7: Provide the file system attributes of the target folder reg add HKCU\Software\Classes\CLSID\%custom_clsid%\Instance\InitPropertyBag /v Attributes /t REG_DWORD /d 0x11 /f rem Step 8: Set the path for the sync root(有的系统使用的是TargetFolderPath,有的是Target) ::reg add HKCU\Software\Classes\CLSID\%custom_clsid%\Instance\InitPropertyBag /v TargetFolderPath /t REG_EXPAND_SZ /d %custom_directory% /f reg add HKCU\Software\Classes\CLSID\%custom_clsid%\Instance\InitPropertyBag /v Target /t REG_EXPAND_SZ /d "%custom_directory%" /f rem Set the sort of the target's attribute tabs (4个属性选项卡可以不添加) reg add "HKCU\Software\Classes\CLSID\%custom_clsid%\ShellEx\PropertySheetHandlers\tab 1 general" /ve /t REG_SZ /d {21b22460-3aea-1069-a2dc-08002b30309d} /f reg add "HKCU\Software\Classes\CLSID\%custom_clsid%\ShellEx\PropertySheetHandlers\tab 2 customize" /ve /t REG_SZ /d {ef43ecfe-2ab9-4632-bf21-58909dd177f0} /f reg add "HKCU\Software\Classes\CLSID\%custom_clsid%\ShellEx\PropertySheetHandlers\tab 3 sharing" /ve /t REG_SZ /d {f81e9010-6ea4-11ce-a7ff-00aa003ca9f6} /f reg add "HKCU\Software\Classes\CLSID\%custom_clsid%\ShellEx\PropertySheetHandlers\tab 4 security" /ve /t REG_SZ /d {1f2e5c40-9550-11ce-99d2-00aa006e086c} /f rem Step 9: Set appropriate shell flags reg add HKCU\Software\Classes\CLSID\%custom_clsid%\ShellFolder /v FolderValueFlags /t REG_DWORD /d 0x28 /f rem Step 10: Set the appropriate flags to control your shell behavior reg add HKCU\Software\Classes\CLSID\%custom_clsid%\ShellFolder /v Attributes /t REG_DWORD /d 0xF080004D /f reg add HKCU\Software\Classes\CLSID\%custom_clsid%\ShellFolder /v HideAsDeletePerUser /t REG_SZ /f reg add HKCU\Software\Classes\CLSID\%custom_clsid%\ShellFolder /v WantsFORPARSING /t REG_SZ /f rem Step 11: Register your extension in the namespace root(关键命令:显示到左侧导航栏根节点下面) reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\%custom_clsid% /ve /t REG_SZ /d %custom_show_name% /f rem (关键命令:显示到左侧导航栏我的电脑节点下面) ::reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\%custom_clsid% /ve /t REG_SZ /d %custom_show_name% /f rem Step 12: Hide your extension from the Desktop(关键命令:如果注册在导航栏根节点下,则需要隐藏桌面上多出的图标) reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel /v %custom_clsid% /t REG_DWORD /d 0x1 /f echo.&echo 已添加注册表:>>%logFile% echo.&echo 已添加注册表: echo %custom_clsid%【%custom_show_name%】【"%custom_directory%"】>>%logFile% echo %custom_clsid%【%custom_show_name%】【"%custom_directory%"】 echo.----------------------------------------------------------- goto endFun :delFun rem 先遍历注册表项,再选择删除指定clsid echo;&echo [%date% %time%] 用户正在删除注册表信息>>%logFile% echo;&echo [%date% %time%] 用户正在删除注册表信息 echo.&echo 开始查找注册表......&echo. set /A regPathCount=1 FOR /L %%i IN (0,1,9) DO set obj_%%i_clsid=&set obj_%%i_foldName=&set obj_%%i_foldPath= ::for /f "tokens=1-4,* delims=\" %%a in ('reg query "%clsidPath%"') do (for /f "tokens=1,2,*" %%i in ('reg query "%%a\%%b\%%c\%%d\%%e" /v "myName"') do (if not "%%i"=="%%a\%%b\%%c\%%d\%%e" set /A regPathCount+=1&set _clsid=!_clsid!%%e )) for /f "tokens=1-4,* delims=\" %%a in ('reg query "%clsidPath%"') do (for /f "tokens=1,2,*" %%i in ('reg query "%%a\%%b\%%c\%%d\%%e" /v "myName" 2^>NUL') do (if not "%%i"=="%%a\%%b\%%c\%%d\%%e" set obj_!regPathCount!_clsid=%%e&set /A regPathCount+=1)) set /A regPathCount-=1 if "%regPathCount%"=="0" echo.&echo.===[WAN:未找到需要删除的注册表项]===&goto endFun set custom_clsid=&set custom_show_name=&set custom_directory= echo 查找到以下注册表项: IF %regPathCount% GTR 1 ( FOR /L %%i IN (1,1,%regPathCount%) DO ( rem read reg default value for /f "tokens=1-3,*" %%a in ('reg query "%clsidPath%\!obj_%%i_clsid!" /ve 2^>NUL') do (if not "%%a"=="%clsidPath%\!obj_%%i_clsid!" set obj_%%i_foldName=%%c) rem read reg folder path value for /f "tokens=1,2,*" %%a in ('reg query "%clsidPath%\!obj_%%i_clsid!\Instance\InitPropertyBag" /v "Target" 2^>NUL') do (if not "%%a"=="%clsidPath%\!obj_%%i_clsid!" set obj_%%i_foldPath=%%c) echo %%i:!obj_%%i_clsid!【!obj_%%i_foldName!】【"!obj_%%i_foldPath!"】 ) echo.&set /p regPathIndex=请选择要删除的注册表序号: FOR /L %%i IN (1,1,%regPathCount%) DO (if %%i==!regPathIndex! set custom_clsid=!obj_%%i_clsid!&set custom_show_name=!obj_%%i_foldName!&set custom_directory=!obj_%%i_foldPath!) ) ELSE ( rem read reg default value for /f "tokens=1-3,*" %%a in ('reg query "%clsidPath%\!obj_%regPathCount%_clsid!" /ve 2^>NUL') do (if not "%%a"=="%clsidPath%\!obj_%regPathCount%_clsid!" set obj_%regPathCount%_foldName=%%c) rem read reg folder path value for /f "tokens=1,2,*" %%a in ('reg query "%clsidPath%\!obj_%regPathCount%_clsid!\Instance\InitPropertyBag" /v "Target" 2^>NUL') do (if not "%%a"=="%clsidPath%\!obj_%regPathCount%_clsid!" set obj_%regPathCount%_foldPath=%%c) set custom_clsid=!obj_%regPathCount%_clsid!&set custom_show_name=!obj_%regPathCount%_foldName!&set custom_directory=!obj_%regPathCount%_foldPath! echo %regPathCount%:!obj_%regPathCount%_clsid!【!obj_%regPathCount%_foldName!】【"!obj_%regPathCount%_foldPath!"】) if "%custom_clsid%"=="" echo.&echo.===[WAN:未指定注册表项]===&goto endFun echo.----------------------------------------------------------- echo 即将删除注册表:>>%logFile% echo 即将删除注册表: echo %custom_clsid%【%custom_show_name%】【"%custom_directory%"】>>%logFile% echo %custom_clsid%【%custom_show_name%】【"%custom_directory%"】 echo.&echo 继续执行请按Y键,终止执行请关闭窗口!&set /p isRun=是否继续执行?[Y/N]: if /i not "%isRun%"=="Y" (echo.&echo.===[WAN:终止删除注册表项]===>>%logFile%&echo.===[WAN:终止删除注册表项]===&goto endFun) reg delete HKCU\Software\Classes\CLSID\%custom_clsid% /f reg delete HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\%custom_clsid% /f reg delete HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel /v %custom_clsid% /f echo.&echo 已删除注册表:>>%logFile% echo.&echo 已删除注册表: echo %custom_clsid%【%custom_show_name%】【"%custom_directory%"】>>%logFile% echo %custom_clsid%【%custom_show_name%】【"%custom_directory%"】 echo.----------------------------------------------------------- goto endFun :endFun echo.&echo 请按任意键退出。&echo. Pause>nul
版本5
优化:1)处理路径最后是\符的异常,2)路径中包含空格的处理等
@ECHO Off&PUSHD "%~DP0"&TITLE windows自定义导航栏脚本-Jack_孟 Setlocal enabledelayedexpansion ::mode con lines=30 cols=60 ::%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit :main echo. set logFile="%~d0\%~nx0_log.txt" echo.----------------------------------------------------------->>%logFile% echo.----------------------------------------------------------- rem 设置3个变量 022d3403-ac03-4117-93be-98dd0e59a4cd ::set custom_clsid={XXXXXXX1-XXXX-XXXX-XXXX-XXXXXXXXXXXX} set custom_clsid={00000000-1111-2222-3333-000000000002} set custom_show_name=myDoc2 set custom_directory=C:\WorkSpace\documents set clsidPath=HKCU\Software\Classes\CLSID echo [%date% %time%] 本文件由 %0 程序写入>>%logFile% echo [%date% %time%] 本文件由 %0 程序写入:%logFile% set isRun= echo. echo.----------------------------------------------------------- echo.如有360、电脑管家等安全软件提醒,请勾选信任允许和不再提醒! echo. echo.请选择使用:(请以管理员身份运行此脚本,否则可能不成功) echo. echo. 1.添加注册表,请输入1 echo. 2.删除注册表,请输入2 echo.----------------------------------------------------------- if exist "%SystemRoot%\System32\choice.exe" goto Win7Choice set /p choice=请输入数字并按回车键确认: echo. if %choice%==1 goto addFun if %choice%==2 goto delFun "set choice=" echo 您输入有误,请重新选择。 ping 127.0.1 -n 1>nul goto main :Win7Choice echo ==Win7Choice== choice /c 12 /n /m "请输入相应数字:" if %errorlevel%==1 goto addFun if %errorlevel%==2 goto delFun goto main :addFun echo;&echo [%date% %time%] 用户正在添加注册表>>%logFile% echo;&echo [%date% %time%] 用户正在添加注册表 echo. set custom_directory= set isFile=1 set /p folderPath=请输入导航路径: rem Format data:remove '' and "" and \ set folderPath='%folderPath%' & set folderPath=%folderPath:'=% set folderPath="%folderPath%" & set folderPath=%folderPath:"=% if "%folderPath:~-1%" equ "\" set folderPath=%folderPath:~,-1% if "%folderPath%"=="" echo.&echo.===[WAN:你未输入任何需要导航的路径]===&goto endFun set custom_directory=%folderPath% pushd %custom_directory% 2>nul&&(popd&set isFile=0) if %isFile%==1 ((for /f "delims=\" %%i in ("%custom_directory%") do set custom_show_name=%%~ni)&(for %%a in ("%custom_directory%") do set custom_directory=%%~dpa)) else (for %%a in ("%custom_directory%") do set custom_show_name=%%~na) if "%custom_directory:~-1%"=="\" set custom_directory=%custom_directory:~0,-1% FOR /F %%a IN ('POWERSHELL -COMMAND "$([guid]::NewGuid().ToString())"') DO (SET custom_clsid={%%a}) set custom_clsid={00000000%custom_clsid:~9% echo.----------------------------------------------------------- echo.&echo 即将添加注册表:>>%logFile% echo.&echo 即将添加注册表: echo %custom_clsid%【%custom_show_name%】【"%custom_directory%"】>>%logFile% echo %custom_clsid%【%custom_show_name%】【"%custom_directory%"】 echo.&echo 继续执行请按Y键,终止执行请关闭窗口!&set /p isRun=是否继续执行?[Y/N]: if /i not "%isRun%"=="Y" (echo.===[WAN:终止添加注册表项]===>>%logFile%&echo.===[WAN:终止添加注册表项]===&goto endFun) ::goto endFun rem 下面的命令就不用改了 rem Step 1: Add your CLSID and name your extension reg add HKCU\Software\Classes\CLSID\%custom_clsid% /ve /t REG_SZ /d "%custom_show_name%" /f rem Step 2: Set the image for your icon reg add HKCU\Software\Classes\CLSID\%custom_clsid%\DefaultIcon /ve /t REG_EXPAND_SZ /d %%SystemRoot%%\system32\shell32.dll,3 /f rem Step 3: Add your extension to the Navigation Pane and make it visible reg add HKCU\Software\Classes\CLSID\%custom_clsid% /v System.IsPinnedToNameSpaceTree /t REG_DWORD /d 0x1 /f rem Step 4: Set the location for your extension in the Navigation Pane reg add HKCU\Software\Classes\CLSID\%custom_clsid% /v SortOrderIndex /t REG_DWORD /d 0x42 /f reg add HKCU\Software\Classes\CLSID\%custom_clsid% /v myName /t REG_SZ /d customNavigator /f rem Step 5: Provide the dll that hosts your extension(可以把shdocvw.dll替换shell32.dll) reg add HKCU\Software\Classes\CLSID\%custom_clsid%\InProcServer32 /ve /t REG_EXPAND_SZ /d %%systemroot%%\system32\shdocvw.dll /f reg add HKCU\Software\Classes\CLSID\%custom_clsid%\InProcServer32 /v ThreadingModel /t REG_SZ /d Both /f rem Step 6: Define the instance object reg add HKCU\Software\Classes\CLSID\%custom_clsid%\Instance /v CLSID /t REG_SZ /d {0afaced1-e828-11d1-9187-b532f1e9575d} /f rem Step 7: Provide the file system attributes of the target folder reg add HKCU\Software\Classes\CLSID\%custom_clsid%\Instance\InitPropertyBag /v Attributes /t REG_DWORD /d 0x11 /f rem Step 8: Set the path for the sync root(有的系统使用的是TargetFolderPath,有的是Target) ::reg add HKCU\Software\Classes\CLSID\%custom_clsid%\Instance\InitPropertyBag /v TargetFolderPath /t REG_EXPAND_SZ /d %custom_directory% /f reg add HKCU\Software\Classes\CLSID\%custom_clsid%\Instance\InitPropertyBag /v Target /t REG_EXPAND_SZ /d "%custom_directory%" /f rem Set the sort of the target's attribute tabs (4个属性选项卡可以不添加) reg add "HKCU\Software\Classes\CLSID\%custom_clsid%\ShellEx\PropertySheetHandlers\tab 1 general" /ve /t REG_SZ /d {21b22460-3aea-1069-a2dc-08002b30309d} /f reg add "HKCU\Software\Classes\CLSID\%custom_clsid%\ShellEx\PropertySheetHandlers\tab 2 customize" /ve /t REG_SZ /d {ef43ecfe-2ab9-4632-bf21-58909dd177f0} /f reg add "HKCU\Software\Classes\CLSID\%custom_clsid%\ShellEx\PropertySheetHandlers\tab 3 sharing" /ve /t REG_SZ /d {f81e9010-6ea4-11ce-a7ff-00aa003ca9f6} /f reg add "HKCU\Software\Classes\CLSID\%custom_clsid%\ShellEx\PropertySheetHandlers\tab 4 security" /ve /t REG_SZ /d {1f2e5c40-9550-11ce-99d2-00aa006e086c} /f rem Step 9: Set appropriate shell flags reg add HKCU\Software\Classes\CLSID\%custom_clsid%\ShellFolder /v FolderValueFlags /t REG_DWORD /d 0x28 /f rem Step 10: Set the appropriate flags to control your shell behavior reg add HKCU\Software\Classes\CLSID\%custom_clsid%\ShellFolder /v Attributes /t REG_DWORD /d 0xF080004D /f reg add HKCU\Software\Classes\CLSID\%custom_clsid%\ShellFolder /v HideAsDeletePerUser /t REG_SZ /f reg add HKCU\Software\Classes\CLSID\%custom_clsid%\ShellFolder /v WantsFORPARSING /t REG_SZ /f rem Step 11: Register your extension in the namespace root(关键命令:显示到左侧导航栏根节点下面) reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\%custom_clsid% /ve /t REG_SZ /d "%custom_show_name%" /f rem (关键命令:显示到左侧导航栏我的电脑节点下面) ::reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\%custom_clsid% /ve /t REG_SZ /d "%custom_show_name%" /f rem Step 12: Hide your extension from the Desktop(关键命令:如果注册在导航栏根节点下,则需要隐藏桌面上多出的图标) reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel /v %custom_clsid% /t REG_DWORD /d 0x1 /f echo.&echo 已添加注册表:>>%logFile% echo.&echo 已添加注册表: echo %custom_clsid%【%custom_show_name%】【"%custom_directory%"】>>%logFile% echo %custom_clsid%【%custom_show_name%】【"%custom_directory%"】 echo.----------------------------------------------------------- goto endFun :delFun rem 先遍历注册表项,再选择删除指定clsid echo;&echo [%date% %time%] 用户正在删除注册表信息>>%logFile% echo;&echo [%date% %time%] 用户正在删除注册表信息 echo.&echo 开始查找注册表......&echo. set /A regPathCount=1 FOR /L %%i IN (0,1,9) DO set obj_%%i_clsid=&set obj_%%i_foldName=&set obj_%%i_foldPath= ::for /f "tokens=1-4,* delims=\" %%a in ('reg query "%clsidPath%"') do (for /f "tokens=1,2,*" %%i in ('reg query "%%a\%%b\%%c\%%d\%%e" /v "myName"') do (if not "%%i"=="%%a\%%b\%%c\%%d\%%e" set /A regPathCount+=1&set _clsid=!_clsid!%%e )) for /f "tokens=1-4,* delims=\" %%a in ('reg query "%clsidPath%"') do (for /f "tokens=1,2,*" %%i in ('reg query "%%a\%%b\%%c\%%d\%%e" /v "myName" 2^>NUL') do (if not "%%i"=="%%a\%%b\%%c\%%d\%%e" set obj_!regPathCount!_clsid=%%e&set /A regPathCount+=1)) set /A regPathCount-=1 if "%regPathCount%"=="0" echo.&echo.===[WAN:未找到需要删除的注册表项]===&goto endFun set custom_clsid=&set custom_show_name=&set custom_directory= echo 查找到以下注册表项: IF %regPathCount% GTR 1 ( FOR /L %%i IN (1,1,%regPathCount%) DO ( rem read reg default value for /f "tokens=1-2,*" %%a in ('reg query "%clsidPath%\!obj_%%i_clsid!" /ve 2^>NUL') do (if not "%%a"=="%clsidPath%\!obj_%%i_clsid!" set obj_%%i_foldName=%%c) rem read reg folder path value for /f "tokens=1,2,*" %%a in ('reg query "%clsidPath%\!obj_%%i_clsid!\Instance\InitPropertyBag" /v "Target" 2^>NUL') do (if not "%%a"=="%clsidPath%\!obj_%%i_clsid!" set obj_%%i_foldPath=%%c) echo %%i:!obj_%%i_clsid!【!obj_%%i_foldName!】【"!obj_%%i_foldPath!"】 ) echo.&set /p regPathIndex=请选择要删除的注册表序号: FOR /L %%i IN (1,1,%regPathCount%) DO (if %%i==!regPathIndex! set custom_clsid=!obj_%%i_clsid!&set custom_show_name=!obj_%%i_foldName!&set custom_directory=!obj_%%i_foldPath!) ) ELSE ( rem read reg default value for /f "tokens=1-2,*" %%a in ('reg query "%clsidPath%\!obj_%regPathCount%_clsid!" /ve 2^>NUL') do (if not "%%a"=="%clsidPath%\!obj_%regPathCount%_clsid!" set obj_%regPathCount%_foldName=%%c) rem read reg folder path value for /f "tokens=1,2,*" %%a in ('reg query "%clsidPath%\!obj_%regPathCount%_clsid!\Instance\InitPropertyBag" /v "Target" 2^>NUL') do (if not "%%a"=="%clsidPath%\!obj_%regPathCount%_clsid!" set obj_%regPathCount%_foldPath=%%c) set custom_clsid=!obj_%regPathCount%_clsid!&set custom_show_name=!obj_%regPathCount%_foldName!&set custom_directory=!obj_%regPathCount%_foldPath! echo %regPathCount%:!obj_%regPathCount%_clsid!【!obj_%regPathCount%_foldName!】【"!obj_%regPathCount%_foldPath!"】) if "%custom_clsid%"=="" echo.&echo.===[WAN:未指定注册表项]===&goto endFun echo.----------------------------------------------------------- echo 即将删除注册表:>>%logFile% echo 即将删除注册表: echo %custom_clsid%【%custom_show_name%】【"%custom_directory%"】>>%logFile% echo %custom_clsid%【%custom_show_name%】【"%custom_directory%"】 echo.&echo 继续执行请按Y键,终止执行请关闭窗口!&set /p isRun=是否继续执行?[Y/N]: echo.&if /i not "%isRun%"=="Y" (echo.&echo.===[WAN:终止删除注册表项]===>>%logFile%&echo.===[WAN:终止删除注册表项]===&goto endFun) reg delete HKCU\Software\Classes\CLSID\%custom_clsid% /f reg delete HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\%custom_clsid% /f reg delete HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel /v %custom_clsid% /f echo.&echo 已删除注册表:>>%logFile% echo.&echo 已删除注册表: echo %custom_clsid%【%custom_show_name%】【"%custom_directory%"】>>%logFile% echo %custom_clsid%【%custom_show_name%】【"%custom_directory%"】 echo.----------------------------------------------------------- goto endFun :endFun echo.&echo 请按任意键退出。&echo. Pause>nul
补充说明
另外在补充几个其他路径,主要也是参考This PC Tweaker软件,大家自己测试看看效果。
HKEY_CURRENT_USER :针对当前登录用户
HKEY_LOCAL_MACHINE:针对本机所有用户
WOW6432Node :针对64位操作系统
[HKEY_CURRENT_USER\Software\Classes\CLSID\{2181e412-eaa9-472c-bc57-22ae264b2983}]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{2181e412-eaa9-472c-bc57-22ae264b2983}]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{2181e412-eaa9-472c-bc57-22ae264b2983}]
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Classes\CLSID\{2181e412-eaa9-472c-bc57-22ae264b2983}]
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{2181e412-eaa9-472c-bc57-22ae264b2983}]
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{2181e412-eaa9-472c-bc57-22ae264b2983}]
关注我】。(●'◡'●)
如果,您希望更容易地发现我的新博客,不妨点击一下绿色通道的【因为,我的写作热情也离不开您的肯定与支持,感谢您的阅读,我是【Jack_孟】!
本文来自博客园,作者:jack_Meng,转载请注明原文链接:https://www.cnblogs.com/mq0036/p/17345787.html
【免责声明】本文来自源于网络,如涉及版权或侵权问题,请及时联系我们,我们将第一时间删除或更改!
posted on 2023-04-23 10:32 jack_Meng 阅读(3089) 评论(0) 编辑 收藏 举报