質問: VBS でFOLDER1
パスとパス文字列を比較する必要があります。FOLDER2
FOLDER1
先ほど保存したテキストファイルから読み込みました。FOLDER2
- [フォルダーの選択] ダイアログから。ユーザーが次の場合に選択できないようにしたいFOLDER2
:
FOLDER2 = FOLDER1
FOLDER2 = FOLDER1\some_folder
FOLDER2 = Parent_Folder\FOLDER1
例:
Folder1 = c:\users\user\Documents
then にFolder2
することはできません: c:\users\user\Documents
、c:\users\user\Documents\Letters
またはc:\users\user\
比較する正しい正規表現を作成できません。現在、次のコードを使用していますが、通常の解決策が必要です。
RightPath = 0
Do
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(0, "Select folder:", &H10&, strPath)
If objFolder Is Nothing Then
msgbox "Configuration canceled" ,64 , "Information"
Wscript.Quit
End If
Set objFolderItem = objFolder.Self
objPath = objFolderItem.Path
' Right now, Check for users folder only
RightPath = RightPath + 1
Dim re, targetString
Set re = New RegExp
With re
.Pattern = "Desktop|Documents|Downloads|Music|Pictures|Videos"
.Global = False
.IgnoreCase = True
End With
targetString = objPath
If re.Test(targetString) Then
msgbox "You cannot choose:" & vbCrLf & vbCrLf & _
"Desktop, Documents, Downloads, Music, Pictures or Videos" & vbCrLf & vbCrLf & _
"Please select another location" ,48 , "Warning!"
RightPath = 0
End If
Loop Until RightPath > 0
msgbox "You selected "+targetString ,0 , "Information,"
Wscript.Quit