VBScript for FInding folder path in system.
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
0 Comments
[ + ] Show comments
Answers (1)
Answer Summary:
http://blogs.technet.com/b/heyscriptingguy/archive/2008/04/17/how-can-i-find-folders-whose-name-fits-a-specified-pattern.aspx
http://blogs.technet.com/b/heyscriptingguy/archive/2008/04/17/how-can-i-find-folders-whose-name-fits-a-specified-pattern.aspx
Please log in to answer
Posted by:
pjgeutjens
12 years ago
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