2012-03-28 170 views
0

我想用VBS 列舉的文件夾列表時exlcude某些子到目前爲止我有:排除在某些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通用文件夾列表,所有用戶,默認等

回答

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