VBS 选择文件夹框

时间:2023-08-18 12:41:44

VBS 选择文件夹框

VBS 选择文件夹框

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
on error resume Next
Const MY_COMPUTER=&H11&
Const WINDOW_HANDLE=0
Const OPTIONS=0
'设置我的电脑为根目录
Set objShell=CreateObject("Shell.Application")
Set objFolder=objShell.Namespace(MY_COMPUTER)
Set objFolderItem=objFolder.Self
strPath=objFolderItem.Path
Set objShell=CreateObject("Shell.Application")
Set objFolder=objShell.BrowseForFolder(WINDOWS_HANDLE,"选择一个文件夹:",OPTIONS,strPath)
If objFolder Is Nothing Then
Wscript.Quit
End If
Set objFolderItem=objFolder.Self
objPath=objFolderItem.Path
If objPath="" Then
Wscript.Quit
Else
Wscript.Echo objPath
End If