标题: 用什么命令可以调用系统“打开”对话框,选择文件夹
[打印本页]
作者: slx8528
时间: 2009-5-8 03:19
标题: 用什么命令可以调用系统“打开”对话框,选择文件夹
用什么命令可以调用系统“打开”对话框,选择文件夹
作者: newxso
时间: 2009-5-8 04:08
@echo off
Wfolder2 "SET Folder=" "C:" "选择文件夹" > temp.bat
call temp.bat
del temp.bat
echo.%Folder%
pause
如果不想用第三方工具,可以用以下VBS:
Const COMPUTER = &H11&
Const WINDOW_HANDLE = 0
Const OPTIONS = 0
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(COMPUTER)
Set objFolderItem = objFolder.Self
strPath = objFolderItem.Path
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder _
(WINDOW_HANDLE, "打开一个文件夹:", OPTIONS, strPath)
If objFolder Is Nothing Then
Wscript.echo "你没有选取一个文件夹!"
Wscript.Quit
End If
Set objFolderItem = objFolder.Self
objPath = objFolderItem.Path
Wscript.Echo objPath
'设置默认打开的目录:
' COMPUTER = &H31& 表示默认打开“网络连接”
' COMPUTER = &H30& 表示默认打开“管理工具”
' COMPUTER = &H29& 表示默认打开“system32”
' COMPUTER = &H28& 表示默认打开“C:\Documents and Settings\Administrator”
' COMPUTER = &H27& 表示默认打开“My Pictures(我的文档中的图片收藏)”
' COMPUTER = &H26& 表示默认打开“Program Files”
' COMPUTER = &H25& 表示默认打开“system32”
' COMPUTER = &H24& 表示默认打开“WINDOWS”
' COMPUTER = &H23& 表示默认打开“Application Data”
' COMPUTER = &H22& 表示默认打开“History”
' COMPUTER = &H21& 表示默认打开“Cookies”
' COMPUTER = &H20& 表示默认打开“Temporary Internet Files”
' COMPUTER = &H19& 表示默认打开“桌面(Administrator)”
' COMPUTER = &H18& 表示默认打开“启动(All Users)”
' COMPUTER = &H17& 表示默认打开“程序(All Users)”
' COMPUTER = &H16& 表示默认打开“「开始」菜单”
' COMPUTER = &H15& 表示默认打开“Templates”
' COMPUTER = &H14& 表示默认打开“Fonts”
' COMPUTER = &H13& 表示默认打开“NetHood”
' COMPUTER = &H12& 表示默认打开“网上邻居”
' COMPUTER = &H11& 表示默认打开“我的电脑”
' COMPUTER = &H10& 表示默认打开“桌面(Administrator)”
' COMPUTER = &H9& 表示默认打开“SendTo”即右键中的“发送到”
' COMPUTER = &H8& 表示默认打开“我最近的文档”
' COMPUTER = &H7& 表示默认打开“启动(Administrator)”
' COMPUTER = &H6& 表示默认打开“收藏夹(Favorites)”
' COMPUTER = &H5& 表示默认打开“我的文档”
' COMPUTER = &H4& 表示默认打开“打印机和传真”
' COMPUTER = &H3& 表示默认打开“控制面板”
' COMPUTER = &H2& 表示默认打开“程序(Administrator)”
' COMPUTER = &H0& 表示默认打开“桌面(Administrator)”
把这个VBS应用到批处理上:
@echo off
(
echo Set objShell=CreateObject^("Shell.Application"^)
echo Set objFolder=objShell.BrowseForFolder _
echo ^(WINDOW_HANDLE,"选择一个文件夹:",OPTIONS,"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"^)
echo If objFolder Is Nothing Then Wscript.Quit
echo Set objFolderItem=objFolder.Self
echo Wsh.Echo objFolderItem.Path
)>BrowseFolder.vbs
for /f "delims=" %%a in ('cscript //nologo BrowseFolder.vbs') do set strFolder=%%a
del BrowseFolder.vbs
echo.%strFolder%
explorer "%strFolder%"
pause
[
Last edited by newxso on 2009-5-8 at 22:35 ]
附件
1:
Wfolder2.rar (2009-5-8 04:08, 4.2 K,下载次数: 40)
作者: slx8528
时间: 2009-5-8 04:24
谢谢,真是太全啦
作者: zgrhcf
时间: 2009-5-10 01:59
Quote: |
Originally posted by newxso at 2009-5-8 04:08:
@echo off
Wfolder2 "SET Folder=" "C:" "选择文件夹" > temp.bat
call temp.bat
del temp.bat
echo.%Folder%
pause
如 ... |
|
谢谢二楼,收下备用了。