.vbs Script to find last modified date of latest files in folder

Hi Guys,

Due to the limitation of sophos on netware we are left not with no report for last AV update at a central location. So we have to go and manually check the status on every server.

So I started to create a batch script to run and verify all the files for the last modified date in a folder on the server which would tell me if the definitions are up to date. Doing this script in batch was limited. So need help creating script in .vbs

Can anyone help create a script which will:
1 - Go check the file modified date in many folders and return the output to a excel or a txt file with the following messages:
"Completed" if the modified date of any file is NOT older than 6 hours.
"Failed" if the modified date of any file is older than 6 hours.

2- The script would have to exclude the .cfg and .log file types from be checked for last modified date.

3-  The script would need a loop and run on many servers which can be listed in a variable at the top of the script. Also amend the output file with the status of every server after a loop.

The folder location on each netware server would be:
<ServerName>\sys\sweep\

Thanks Guys
harps21kAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rejoinderCommented:
Just to clarify - you want to check the times of all files with the exception of .log and .cfg files that are located in a number of folders.  If even one of the files within any of the folders is older than 6 hours report a failure otherwise the machine is up to date?
0
harps21kAuthor Commented:
Yeh I would like it to check for everything except the .cfg and .log file.

Basically I need it to query for anyone of the most recent updated file and report as failed if that file has been modified older than 6hours.  Also report as completed if the most recent updated file is newer than 6hours.

I don't know which file would be updated that why I need it to query for anyone of the files to find at least 1 recent modified file to report the update status. Also have the exclusion mentioned above.

Thanks
0
merowingerCommented:
This should do it. I've only a restricted testing environemt, but for what i saw it should work
set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & "." & "\root\cimv2")
Set objPCs = objFSO.OpenTextFile("D:\Computers.txt")
Set objOutput = objFSO.CreateTextFile("D:\Output.log")
bolFilesOlder = False
strFolder = "sys\sweep"

Do While Not objPCs.AtEndOfStream
	strCurrentPC = objPCs.ReadLine
	
	'First check connection to the PC
	Set colPing = objWMIService.ExecQuery("Select * from Win32_PingStatus Where Address = '" &strCurrentPC &"'")
	For Each objPing In colPing
		If objPing.StatusCode = 0 Then
			Call CheckFiles ("\\" &strCurrentPC &"\" &strFolder)
			If bolFilesOlder = True Then
				objOutput.WriteLine strCurrentPC &" - Failed"
			Else
				objOutput.WriteLine strCurrentPC &" - Completed"
			End If
			bolFilesOlder = False
		Else
			objOutput.WriteLine strCurrentPC &" is not online"
		End If
	
	Next
Loop

Sub CheckFiles(Folder)
WScript.Echo Folder
Set curFolder = objFSO.GetFolder(Folder)
For Each file in curFolder.Files
	If UCASE(Right(file,3)) <> "LOG" And UCASE(Right(file,3)) <> "CFG" Then
		strDateModified = objFSO.GetFile(file).DateLastModified
		If DateAdd("h",6,strDateModified) < Now Then bolFilesOlder = True
	End If
Next

For Each subfolder In curFolder.SubFolders
	CheckFiles(subfolder)
Next

End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
harps21kAuthor Commented:
Testing
0
merowingerCommented:
Any update?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Anti-Virus Apps

From novice to tech pro — start learning today.