Windows Script Host uses VBS to implement the Browse folder feature _vbs
Source: Internet
Author: User
'************************************************
' File:Dialog.vbs (WSH sample in VBScript)
' Author: (c) G. Born
'
' Using the Shell dialog box to select a folder
'************************************************
Option Explicit
' Flags for the options parameter
Const Bif_returnonlyfsdirs = &h0001
Const bif_dontgobelowdomain= &h0002
Const Bif_statustext = &h0004
Const bif_returnfsancestors= &h0008
Const bif_editbox= &h0010
Const bif_validate = &h0020
Const bif_browseforcomputer= &h1000
Const Bif_browseforprinter = &h2000
Const bif_browseincludefiles = &h4000
Dim WSH, Objdlg, OBJF
' Get Application object of the Windows shell.
Set Objdlg = WScript.CreateObject ("Shell.Application")
' Use of the BrowseForFolder method.
' for Instance:set OBJF = Objdlg.browseforfolder _
' (&h0, "Select the folder to copy", &h10, "C:\Born")
Set OBJF = Objdlg.browseforfolder (&h0, _
"Select the folder to copy", _
Bif_editbox + bif_returnonlyfsdirs)
' Here we use the ' the ' the ' the ' the ' Detect '
If Isvalue (OBJF) Then
MsgBox "Selected folder:" & Objf.title
Else
MsgBox "Canceled"
End If
' Here we use TypeName to detect the result.
If InStr (1, TypeName (OBJF), "folder") > 0 Then
MsgBox "Selected folder:" & Objf.title
Else
MsgBox "Canceled"
End If
Function Isvalue (obj)
' Check whether the value has been returned.
Dim tmp
On Error Resume Next
TMP = "" & obj
If Err <> 0 Then
Isvalue = False
Else
Isvalue = True
End If
On Error GoTo 0
End Function
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.