Windows 资源管理器导航窗格中的自定义条目

Windows 资源管理器导航窗格中的自定义条目

有人知道如何在资源管理器导航窗格中(就在新主页条目下方)创建新条目吗?

我已经编写了一个可以创建自定义条目的代码,并且已经尝试设置不同的排序顺序索引值,但没有运气——我只实现了将自定义条目移动到主页上方,这不是我想要的。

:: Settings
SET CLSID={CUSTOM_CLSID}
SET ICON=%%USERPROFILE%%\Pictures\Icons\googledrive.ico,0
SET NAME=Google Drive
SET /A ORDER=65
SET STORAGE=%%USERPROFILE%%\Google Drive

:: Create Explorer entry
REG ADD "HKCU\Software\Classes\Wow6432Node\CLSID\%CLSID%" /ve /t REG_SZ /d "%NAME%" /f
REG ADD "HKCU\Software\Classes\Wow6432Node\CLSID\%CLSID%" /v "System.IsPinnedToNamespaceTree" /t REG_DWORD /d "1" /f
REG ADD "HKCU\Software\Classes\Wow6432Node\CLSID\%CLSID%" /v "SortOrderIndex" /t REG_DWORD /d "%ORDER%" /f
REG ADD "HKCU\Software\Classes\Wow6432Node\CLSID\%CLSID%\InProcServer32" /ve /t REG_EXPAND_SZ /d "%%SYSTEMROOT%%\system32\shell32.dll" /f
REG ADD "HKCU\Software\Classes\Wow6432Node\CLSID\%CLSID%\ShellFolder" /v "FolderValueFlags" /t REG_DWORD /d "40" /f
REG ADD "HKCU\Software\Classes\Wow6432Node\CLSID\%CLSID%\ShellFolder" /v "Attributes" /t REG_DWORD /d "4034920525" /f
REG ADD "HKCU\Software\Classes\CLSID\%CLSID%" /ve /t REG_SZ /d "%NAME%" /f
REG ADD "HKCU\Software\Classes\CLSID\%CLSID%" /v "System.IsPinnedToNamespaceTree" /t REG_DWORD /d "1" /f
REG ADD "HKCU\Software\Classes\CLSID\%CLSID%" /v "SortOrderIndex" /t REG_DWORD /d "%ORDER%" /f
REG ADD "HKCU\Software\Classes\CLSID\%CLSID%\InProcServer32" /ve /t REG_EXPAND_SZ /d "%%SYSTEMROOT%%\system32\shell32.dll" /f
REG ADD "HKCU\Software\Classes\CLSID\%CLSID%\ShellFolder" /v "FolderValueFlags" /t REG_DWORD /d "40" /f
REG ADD "HKCU\Software\Classes\CLSID\%CLSID%\ShellFolder" /v "Attributes" /t REG_DWORD /d "4034920525" /f
REG ADD "HKCU\Software\Classes\Wow6432Node\CLSID\%CLSID%\DefaultIcon" /ve /t REG_EXPAND_SZ /d "%ICON%" /f
REG ADD "HKCU\Software\Classes\Wow6432Node\CLSID\%CLSID%\Instance" /v "CLSID" /t REG_SZ /d "{0E5AAE11-A475-4c5b-AB00-C66DE400274E}" /f
REG ADD "HKCU\Software\Classes\Wow6432Node\CLSID\%CLSID%\Instance\InitPropertyBag" /v "Attributes" /t REG_DWORD /d "17" /f
REG ADD "HKCU\Software\Classes\CLSID\%CLSID%\DefaultIcon" /ve /t REG_EXPAND_SZ /d "%ICON%" /f
REG ADD "HKCU\Software\Classes\CLSID\%CLSID%\Instance" /v "CLSID" /t REG_SZ /d "{0E5AAE11-A475-4c5b-AB00-C66DE400274E}" /f
REG ADD "HKCU\Software\Classes\CLSID\%CLSID%\Instance\InitPropertyBag" /v "Attributes" /t REG_DWORD /d "17" /f
REG ADD "HKCU\Software\Classes\CLSID\%CLSID%\Instance\InitPropertyBag" /v "TargetFolderPath" /t REG_EXPAND_SZ /d "%STORAGE%" /f
REG ADD "HKCU\Software\Classes\Wow6432Node\CLSID\%CLSID%\Instance\InitPropertyBag" /v "TargetFolderPath" /t REG_EXPAND_SZ /d "%STORAGE%" /f
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" /v "%CLSID%" /t REG_DWORD /d "1" /f
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\%CLSID%" /ve /t REG_SZ /d "%NAME%" /f

预期结果

答案1

好的,经过一番研究,我找到了实现我想要的方法。

默认排序顺序索引条目为 64。下一个条目是默认条目一个驱动器(018D5C66-4533-4307-9B53-224DE2ED1FE6),索引为 66。设置排序顺序索引对于我们的自定义条目,将其推到第一个导航窗格部分的顶部条目,同时将其设置为更大的值(例如 65),并将其移动到最后一节这台电脑入口。

自定义条目,SortOrderIndex 设置为 64
SortOrderIndex 大于 64 的自定义条目

我不知道为什么索引为 66 的 OneDrive 仍然位于主页条目下方的顶部部分,而任何自定义内容都发送到最后一部分,但我设法通过设置解决了该问题排序顺序索引对于我们的(f874310e-b6b7-47dc-bc84-b9e6b38f5903)输入较低的值(即 50),这是通过在 HKCU 中使用正确的 CLSID 创建密钥来完成的:

REG ADD "HKCU\Software\Classes\CLSID\%QUICK_ACCESS_CLSID%" /f >NUL 2>&1
REG ADD "HKCU\Software\Classes\CLSID\%QUICK_ACCESS_CLSID%" /v "SortOrderIndex" /t REG_DWORD /d "%QUICK_ACCESS_ORDER%" /f >NUL 2>&1
REG ADD "HKCU\Software\Classes\Wow6432Node\CLSID\%QUICK_ACCESS_CLSID%" /f >NUL 2>&1
REG ADD "HKCU\Software\Classes\Wow6432Node\CLSID\%QUICK_ACCESS_CLSID%" /v "SortOrderIndex" /t REG_DWORD /d "%QUICK_ACCESS_ORDER%" /f >NUL 2>&1

此后,第一部分中我们又增加了 14 个名额用于新参赛作品,从第 51 名到第 64 名。


这是一个脚本,它将在下面创建新的导航窗格条目入口。

要自定义它,请更改部分中的变量:Custom entry settings。另外,不要忘记为新条目生成唯一的 CLSID。您可以复制此文件,再次更改 CLSID,然后对多个自定义条目重复整个过程。

使用相同设置第二次启动脚本将删除自定义条目,请参阅:ELEMENT_EXISTS部分。

@ECHO OFF

:: Checking for administrator rights using fsutil which will only work if under 
:: admin rights which just queries the volume here %systemdrive% 
:: for a 'dirty bit' for corrupted volume 
:: WITHOUT TOUCHING ANY FILES/REGISTERY ANYTHING at all
:: source >> https://stackoverflow.com/a/21295806

:: Using an elevated runas cmd prompt/powershell is deliberately avoided 
:: for security/privacy reasons and to have a SYSTEM-LESS way
FSUTIL dirty QUERY %systemdrive% >NUL
IF %ERRORLEVEL% GTR 0 GOTO NO_ADMIN_ERROR

:: Custom entry settings
SET ENTRY_CLSID={018D5C66-1111-4307-9B53-224DE2ED1FE5}
SET ENTRY_ICON=%%USERPROFILE%%\Pictures\Icons\googledrive.ico,0
SET ENTRY_NAME=Google Drive
SET ENTRY_ORDER=64
SET ENTRY_TARGET=%%USERPROFILE%%\Insync\[email protected]\Google Drive

:: QUICK_ACCESS_CLSID :: Home entry CLSID - shouldn't be changed
:: QUICK_ACCESS_ORDER :: Home entry order position - this will allow us to set custom entry below `Home` entry
:: 
:: This will also change Home entry sort order - to restore default value (64), delete following keys from registry:
:: HKCU\Software\Classes\CLSID\%QUICK_ACCESS_CLSID%
:: HKCU\Software\Classes\Wow6432Node\CLSID\%QUICK_ACCESS_CLSID%
:: --- YES, delete this keys completly as they are custom created by this script
SET QUICK_ACCESS_CLSID={f874310e-b6b7-47dc-bc84-b9e6b38f5903}
SET QUICK_ACCESS_ORDER=50

:: Check if CLSID already exists
REG QUERY HKEY_CLASSES_ROOT\CLSID\%ENTRY_CLSID% >NUL 2>&1 
IF %ERRORLEVEL% GTR 0 GOTO CREATE_ELEMENT
GOTO ELEMENT_EXISTS

:: Create Explorer entry
:CREATE_ELEMENT
REG ADD "HKCU\Software\Classes\CLSID\%ENTRY_CLSID%" /ve /t REG_SZ /d "%ENTRY_NAME%" /f >NUL 2>&1
REG ADD "HKCU\Software\Classes\CLSID\%ENTRY_CLSID%" /v "IsCustom" /t REG_DWORD /d "1" /f >NUL 2>&1
REG ADD "HKCU\Software\Classes\CLSID\%ENTRY_CLSID%" /v "SortOrderIndex" /t REG_DWORD /d "%ENTRY_ORDER%" /f >NUL 2>&1
REG ADD "HKCU\Software\Classes\CLSID\%ENTRY_CLSID%" /v "System.IsPinnedToNamespaceTree" /t REG_DWORD /d "1" /f >NUL 2>&1
REG ADD "HKCU\Software\Classes\CLSID\%ENTRY_CLSID%\DefaultIcon" /ve /t REG_EXPAND_SZ /d "%ENTRY_ICON%" /f >NUL 2>&1
REG ADD "HKCU\Software\Classes\CLSID\%ENTRY_CLSID%\InProcServer32" /ve /t REG_EXPAND_SZ /d "%%SYSTEMROOT%%\system32\shell32.dll" /f >NUL 2>&1
REG ADD "HKCU\Software\Classes\CLSID\%ENTRY_CLSID%\Instance" /v "CLSID" /t REG_SZ /d "{0E5AAE11-A475-4c5b-AB00-C66DE400274E}" /f >NUL 2>&1
REG ADD "HKCU\Software\Classes\CLSID\%ENTRY_CLSID%\Instance\InitPropertyBag" /v "Attributes" /t REG_DWORD /d "17" /f >NUL 2>&1
REG ADD "HKCU\Software\Classes\CLSID\%ENTRY_CLSID%\Instance\InitPropertyBag" /v "TargetFolderPath" /t REG_EXPAND_SZ /d "%ENTRY_TARGET%" /f >NUL 2>&1
REG ADD "HKCU\Software\Classes\CLSID\%ENTRY_CLSID%\ShellFolder" /v "Attributes" /t REG_DWORD /d "4034920525" /f >NUL 2>&1
REG ADD "HKCU\Software\Classes\CLSID\%ENTRY_CLSID%\ShellFolder" /v "FolderValueFlags" /t REG_DWORD /d "40" /f >NUL 2>&1
REG ADD "HKCU\Software\Classes\CLSID\%QUICK_ACCESS_CLSID%" /f >NUL 2>&1
REG ADD "HKCU\Software\Classes\CLSID\%QUICK_ACCESS_CLSID%" /v "SortOrderIndex" /t REG_DWORD /d "%QUICK_ACCESS_ORDER%" /f >NUL 2>&1
REG ADD "HKCU\Software\Classes\Wow6432Node\CLSID\%ENTRY_CLSID%" /ve /t REG_SZ /d "%ENTRY_NAME%" /f >NUL 2>&1
REG ADD "HKCU\Software\Classes\Wow6432Node\CLSID\%ENTRY_CLSID%" /v "IsCustom" /t REG_DWORD /d "1" /f >NUL 2>&1
REG ADD "HKCU\Software\Classes\Wow6432Node\CLSID\%ENTRY_CLSID%" /v "SortOrderIndex" /t REG_DWORD /d "%ENTRY_ORDER%" /f >NUL 2>&1
REG ADD "HKCU\Software\Classes\Wow6432Node\CLSID\%ENTRY_CLSID%" /v "System.IsPinnedToNamespaceTree" /t REG_DWORD /d "1" /f >NUL 2>&1
REG ADD "HKCU\Software\Classes\Wow6432Node\CLSID\%ENTRY_CLSID%\DefaultIcon" /ve /t REG_EXPAND_SZ /d "%ENTRY_ICON%" /f >NUL 2>&1
REG ADD "HKCU\Software\Classes\Wow6432Node\CLSID\%ENTRY_CLSID%\InProcServer32" /ve /t REG_EXPAND_SZ /d "%%SYSTEMROOT%%\system32\shell32.dll" /f >NUL 2>&1
REG ADD "HKCU\Software\Classes\Wow6432Node\CLSID\%ENTRY_CLSID%\Instance" /v "CLSID" /t REG_SZ /d "{0E5AAE11-A475-4c5b-AB00-C66DE400274E}" /f >NUL 2>&1
REG ADD "HKCU\Software\Classes\Wow6432Node\CLSID\%ENTRY_CLSID%\Instance\InitPropertyBag" /v "Attributes" /t REG_DWORD /d "17" /f >NUL 2>&1
REG ADD "HKCU\Software\Classes\Wow6432Node\CLSID\%ENTRY_CLSID%\Instance\InitPropertyBag" /v "TargetFolderPath" /t REG_EXPAND_SZ /d "%ENTRY_TARGET%" /f >NUL 2>&1
REG ADD "HKCU\Software\Classes\Wow6432Node\CLSID\%ENTRY_CLSID%\ShellFolder" /v "Attributes" /t REG_DWORD /d "4034920525" /f >NUL 2>&1
REG ADD "HKCU\Software\Classes\Wow6432Node\CLSID\%ENTRY_CLSID%\ShellFolder" /v "FolderValueFlags" /t REG_DWORD /d "40" /f >NUL 2>&1
REG ADD "HKCU\Software\Classes\Wow6432Node\CLSID\%QUICK_ACCESS_CLSID%" /f >NUL 2>&1
REG ADD "HKCU\Software\Classes\Wow6432Node\CLSID\%QUICK_ACCESS_CLSID%" /v "SortOrderIndex" /t REG_DWORD /d "%QUICK_ACCESS_ORDER%" /f >NUL 2>&1
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\%ENTRY_CLSID%" /ve /t REG_SZ /d "%ENTRY_NAME%" /f >NUL 2>&1
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" /v "%ENTRY_CLSID%" /t REG_DWORD /d "1" /f >NUL 2>&1
ECHO Entry created successfully.
GOTO :EOF

:: Check if CLSID points to custom created entry
:ELEMENT_EXISTS
REG QUERY HKEY_CLASSES_ROOT\CLSID\%ENTRY_CLSID% /v IsCustom >NUL 2>&1
IF %ERRORLEVEL% == 0 GOTO DELETE_ELEMENT
ECHO [ERROR] CLSID %ENTRY_CLSID% already exists.
ECHO Change it and try again.
GOTO :EOF

:: Delete Explorer entry
:DELETE_ELEMENT
REG DELETE "HKCU\Software\Classes\CLSID\%ENTRY_CLSID%" /f >NUL 2>&1
REG DELETE "HKCU\Software\Classes\Wow6432Node\CLSID\%ENTRY_CLSID%" /f >NUL 2>&1
REG DELETE "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\%ENTRY_CLSID%" /f >NUL 2>&1
REG DELETE "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" /v "%ENTRY_CLSID%" /f >NUL 2>&1
ECHO Entry deleted successfully.
GOTO :EOF

:: Error message for reference
:NO_ADMIN_ERROR
ECHO [ERROR] This script needs to be executed as an administrator.
PAUSE
GOTO :EOF

这是结果

相关内容