Explorer.exe shell:<dir> 路径
Explorer.exe shell:<dir> path
有什么方法可以在不直接在我的文件中使用注册表的情况下将 path 从 explorer.exe shell:<dir>
获取到批处理文件中的变量?
Switches 在这种情况下似乎没有用。
您可以使用 Windows 脚本宿主语言来获取 WshShell.SpecialFolders
property。示例批处理 + JScript 混合解决方案(应提供 .bat 扩展名):
@if (@CodeSection == @Batch) @then
@echo off & setlocal
call :getSpecialFolder AllUsersDesktop
echo %AllUsersDesktop%
call :getSpecialFolder Fonts
echo %Fonts%
goto :EOF
:getSpecialFolder <folderName=returnValue>
for /f "delims=" %%I in ('cscript /nologo /e:JScript "%~f0" "%~1"') do set "%~1=%%I"
goto :EOF
@end // end batch begin JScript
WSH.Echo(WSH.CreateObject('WScript.Shell').SpecialFolders(WSH.Arguments(0)));
来自 MSDN 文档:
The WshSpecialFolders object is a collection. It contains the entire set of Windows special folders, such as the Desktop folder, the Start Menu folder, and the Personal Documents folder. The special folder name is used to index into the collection to retrieve the special folder you want. The SpecialFolders property returns an empty string if the requested folder (strFolderName) is not available. For example, Windows 95 does not have an AllUsersDesktop folder and returns an empty string if strFolderNameis AllUsersDesktop.
The following special folders are available:
- AllUsersDesktop
- AllUsersStartMenu
- AllUsersPrograms
- AllUsersStartup
- Desktop
- Favorites
- Fonts
- MyDocuments
- NetHood
- PrintHood
- Programs
- Recent
- SendTo
- StartMenu
- Startup
- Templates
有什么方法可以在不直接在我的文件中使用注册表的情况下将 path 从 explorer.exe shell:<dir>
获取到批处理文件中的变量?
Switches 在这种情况下似乎没有用。
您可以使用 Windows 脚本宿主语言来获取 WshShell.SpecialFolders
property。示例批处理 + JScript 混合解决方案(应提供 .bat 扩展名):
@if (@CodeSection == @Batch) @then
@echo off & setlocal
call :getSpecialFolder AllUsersDesktop
echo %AllUsersDesktop%
call :getSpecialFolder Fonts
echo %Fonts%
goto :EOF
:getSpecialFolder <folderName=returnValue>
for /f "delims=" %%I in ('cscript /nologo /e:JScript "%~f0" "%~1"') do set "%~1=%%I"
goto :EOF
@end // end batch begin JScript
WSH.Echo(WSH.CreateObject('WScript.Shell').SpecialFolders(WSH.Arguments(0)));
来自 MSDN 文档:
The WshSpecialFolders object is a collection. It contains the entire set of Windows special folders, such as the Desktop folder, the Start Menu folder, and the Personal Documents folder. The special folder name is used to index into the collection to retrieve the special folder you want. The SpecialFolders property returns an empty string if the requested folder (strFolderName) is not available. For example, Windows 95 does not have an AllUsersDesktop folder and returns an empty string if strFolderNameis AllUsersDesktop.
The following special folders are available:
- AllUsersDesktop
- AllUsersStartMenu
- AllUsersPrograms
- AllUsersStartup
- Desktop
- Favorites
- Fonts
- MyDocuments
- NetHood
- PrintHood
- Programs
- Recent
- SendTo
- StartMenu
- Startup
- Templates