我在使用vbs枚举文件夹列表时试图浏览某些子文件夹 到目前为止我有:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\Users\")
Set colSubfolders = objFolder.Subfolders
For Each objSubfolder in colSubfolders
wscript.echo objSubfolder.Name
Next
返回:
所有用户 默认 默认用户 詹姆士 迈克尔 上市 西蒙
我想为通用文件夹创建一个exlcusion列表,All Users,Default etc
答案 0 :(得分:1)
您需要知道要排除哪些,然后使用条件语句。
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\Users\")
Set colSubfolders = objFolder.Subfolders
For Each objSubfolder in colSubfolders
If objSubfolder.Name <> "All Users" And objSubfolder.Name <> "Default" _
And objSubfolder.Name <> "Default User" And objSubfolder.Name <> "Public" Then
WScript.echo objSubfolder.Name
End If
Next