HI Team,

i have searched many ways in google but i didn't find my script.

 

Q: i am giveing one folder name like "ITNINJA" , we need search entire system (C, D , E .... drives) and found a folder respective name "ITNINJA" and we need to display "ITNINJA" folder path.

 

any please help me out

 

Thanks

appinstall

Answer Summary:
http://blogs.technet.com/b/heyscriptingguy/archive/2008/04/17/how-can-i-find-folders-whose-name-fits-a-specified-pattern.aspx
Cancel
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Answers

0
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Global = True   
objRegEx.IgnoreCase = True
objRegEx.Pattern = "^bad_\d{8}"
strComputer = "." 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colFolders = objWMIService.ExecQuery("Select * From Win32_Directory")
For Each objFolder in colFolders
    strFolder = objFolder.FileName
    Set colMatches = objRegEx.Execute(strFolder)
    If colMatches.Count > 0 Then
        Wscript.Echo objFolder.Name
    End If
Next

 

source: http://blogs.technet.com/b/heyscriptingguy/archive/2008/04/17/how-can-i-find-folders-whose-name-fits-a-specified-pattern.aspx

Answered 05/10/2012 by: pjgeutjens
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity

Share