' **************************************************************************** ' * ' * author fabian wleklinski (wleklinski@eworks.de) ' * date 2003-04-24 ' * url http://www.eworks.de/research/2003/04/CvsFolderHider/ ' * (c) eWorks 2003 (http://www.eworks.de) ' * ' * CvsFolderHider searches for folders named "CVS" below a certain folder, ' * and hides them, so normal users can't see them anymore. ' * ' **************************************************************************** ' Copyright-Information Const Copyright = "(c) 2003 eWorks (http://www.eWorks.de)" ' Application-Information Const sApplicationTitle = "CvsFolderHider" ' Scans the given folder for subfolders named "CVS", and hides them. After ' that, the method calls itself recursively for every single subfolder (except ' the ones named "CVS"). If everything went okay, it returns the number of ' folders that have been hidden (>= 0), else an error-code. ' public Function processFolder( sFolder ) ' the result value iResult = 0 ' get an instance of the FileSystemObject-class Set oFSO = CreateObject( "Scripting.FileSystemObject" ) ' access the source-files-folder Set oSourceFolder = oFSO.GetFolder( sFolder ) ' get all subfolders inside the source-folder Set oSubFolders = oSourceFolder.SubFolders ' iterate trough all subfolders inside the source-folder For each oSubFolder in oSubFolders If (StrComp(oSubFolder.Name, "CVS", 1) = 0) Then ' folder is named "CVS" => hide folder If ((oSubFolder.Attributes and 2) = 0) Then oSubFolder.Attributes = oSubFolder.Attributes or 2 iResult = iResult + 1 End If Else ' folder isn't named "CVS" => step down iTempResult = processFolder( oSubfolder.Path ) ' error? => return error If (iTempResult < 0) Then processError = iTempResult Exit Function End If iResult = iResult + iTempResult End If Next ' return the result processFolder = iResult End Function ' check if there is a command line parameter describing the folder to be ' processed If (WScript.Arguments.Count <> 1) Then MsgBox "usage: CvsFolderHider.vbs [foldername]", 48, sApplicationTitle WScript.Quit 1 End If ' define the folder to be processed sFolder = WScript.Arguments(0) ' start the processing, beginning with the given folder iResult = processFolder( sFolder ) ' output information If (iResult > 0) Then MsgBox iResult & " non-hidden subfolder(s) below " & sFolder & _ " have been found named ""CVS"". They have been hidden.", _ 64, sApplicationTitle ElseIf (iResult < 0) Then MsgBox "An error has occured.", 64, sApplicationTitle Else MsgBox "No non-hidden subfolders below " & sFolder & " have been " & _ "found named ""CVS""." & vbCr & "Nothing has been done.", _ 64, sApplicationTitle End If