Hey guys, im very new to VBS, this is my first attempt at it.
I am trying to write a script that will;
1) Search a Folder/Subfolders for files that have a LastModified date equal to todays date
2) Return the FileName, Extention, LastModified, User who modified
3) Output eat file found to a registry key
I have managed to create a script to do 1 & most of 2 but i dont understand how i would get around to scripting part 3.
here is what i have so far
On Error Resume Next
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
arrComputers = Array("EMEAOXFLP130")
For Each strComputer In arrComputers
WScript.Echo
WScript.Echo "=========================================="
WScript.Echo "Computer: " & strComputer
WScript.Echo "=========================================="
WScript.Echo"Date: " & Date
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM CIM_DataFile WHERE Drive='C:' AND Path like '%CRS%' AND Extension = 'txt'", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
IF WMIDateStringToDate(objItem.LastModified) = Date then
WScript.Echo "FileName: " & objItem.FileName
WScript.Echo "Extension: " & objItem.Extension
WScript.Echo "LastModified: " & WMIDateStringToDate(objItem.LastModified)
WScript.Echo "Name: " & objItem.Name
WScript.Echo "========================================"
Else
End If
Next
Next
Function WMIDateStringToDate(dtmDate)
WScript.Echo dtm:
WMIDateStringToDate = CDate(Mid(dtmDate, 7, 2) & "/" & Mid(dtmDate, 5, 2) & "/" & Left(dtmDate, 4))
End Function
If any of you guys could help me i would be forever in your debt..
Thanks in advance
I am trying to write a script that will;
1) Search a Folder/Subfolders for files that have a LastModified date equal to todays date
2) Return the FileName, Extention, LastModified, User who modified
3) Output eat file found to a registry key
I have managed to create a script to do 1 & most of 2 but i dont understand how i would get around to scripting part 3.
here is what i have so far
On Error Resume Next
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
arrComputers = Array("EMEAOXFLP130")
For Each strComputer In arrComputers
WScript.Echo
WScript.Echo "=========================================="
WScript.Echo "Computer: " & strComputer
WScript.Echo "=========================================="
WScript.Echo"Date: " & Date
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM CIM_DataFile WHERE Drive='C:' AND Path like '%CRS%' AND Extension = 'txt'", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
IF WMIDateStringToDate(objItem.LastModified) = Date then
WScript.Echo "FileName: " & objItem.FileName
WScript.Echo "Extension: " & objItem.Extension
WScript.Echo "LastModified: " & WMIDateStringToDate(objItem.LastModified)
WScript.Echo "Name: " & objItem.Name
WScript.Echo "========================================"
Else
End If
Next
Next
Function WMIDateStringToDate(dtmDate)
WScript.Echo dtm:
WMIDateStringToDate = CDate(Mid(dtmDate, 7, 2) & "/" & Mid(dtmDate, 5, 2) & "/" & Left(dtmDate, 4))
End Function
If any of you guys could help me i would be forever in your debt..
Thanks in advance