Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Locate files using a vb script

$
0
0

Hi everybody,

I am a network guy with 0 programmings skills :) I'm getting better with scripting slowly but surely...

I have a customer that needs to find where are located Groupewise archives for around 80 users. We will then move them to a specific location on the network. The customer will do this manually since they have configuration change to do on each mailbox.

The archive name are always in this format OF???ARC .

My script work but only for explicit file name. I would need to use a regex or something so my search result find the files.

I need to search on c:\*.* because they could be possibly everywhere.

I dont need to do any action on the files just find them and write result to file. Like I said I have no programming skills and I found all the piece looking on forums.

Thanks for your help, it is probably a small thing but I cant manage to find it.

Regards,

Mathieu

See my script is below

I did REM my objregex since its not working anyway.

Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
Set WshNetwork = CreateObject("WScript.Network")
strComputer = WshNetwork.ComputerName

RemSet objRegEx = CreateObject("VBScript.RegExp")
RemobjRegEx.Pattern = "OF...ARC"

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colFiles = objWMIService.ExecQuery _
    ("Select * from CIM_DataFile Where Filename = 'OFxyxARC' ") 

If colFiles.Count = 0Then
   WScript.echo ("no file found")
Rem  Wscript.quit
EndIf


    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objTextFile = objFSO.CreateTextFile("c:\scripts\" & strComputer & ".txt")

ForEach objFilein colFiles
    objTextFile.Write(objFile.Drive & objFile.Path & ",")
    objTextFile.Write(objFile.FileName & "." & objFile.Extension & ",")
    objTextFile.Write(objFile.FileSize & vbCrLf)
Next

objTextFile.Close

By the way. I can't use powershell. Only Windows XP with a lot of missing patches and Windows 2003 servers available in the forest/domain



Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>