Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8223195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:36:06+00:00 2026-06-07T14:36:06+00:00

Goal: To run a VBScript that checks a folder daily, and reports if no

  • 0

Goal: To run a VBScript that checks a folder daily, and reports if no files were saved to it that day. Ignore the files that exist from previous days.

Scenario: A logfile is created everyday in C:\Temp at 3am. This is what tells us that the system performed a task. If a log file isn’t generated, then the task crashed. I wrote this to check the Temp folder for a file created today, and to email me if it doesn’t exist.

Solution thus far:

option explicit 
dim fileSystem, folder, file 
dim path  
path = "C:\Temp" 

Set fileSystem = CreateObject("Scripting.FileSystemObject") 
Set folder = fileSystem.GetFolder(path) 

for each file in folder.Files     
  if file.DateLastModified > dateadd("h", -24, Now) then 
'WScript.Echo file.Name & " last modified at " & file.DateLastModified 
else 
SendEmail
'WScript.Echo "this should have sent an email."
  end if 
next 

Function SendEmail() 
 'Send Email notification function here (this part works already)
End Function

Issue I am having:

I can’t seem to wrap my head around a way to have the script ignore files in the folder from previous days.

In my test, I have C:\Temp populuated with a file modified today, and a file modified on 7/10/12. Because this scenario matches both the ‘then’ and the ‘else’ statement, it’s doing both.

I think I just need a slight modification on the loop to tell it
– Ignore files not dated ‘today’
– Send an email if no files exist today.

Any help would be awesome. I just can’t seem to ‘see’ the answer.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T14:36:10+00:00Added an answer on June 7, 2026 at 2:36 pm

    You’re close. The problem is is you were looping through and checking every single file. You need to only check if one file doesn’t exist. I’m not that familiar with vbscript, so you may need to tweak this a bit, but what I did is add a variable found and initialized it to false. If you find a file created in past 24 hours, set it to true. once you’re done looping, if it’s still false, no files were modified in past 24 hours

    option explicit 
    dim fileSystem, folder, file 
    dim path  
    Dim found
    found = false
    path = "C:\Temp" 
    
    Set fileSystem = CreateObject("Scripting.FileSystemObject") 
    Set folder = fileSystem.GetFolder(path) 
    
    for each file in folder.Files     
      if file.DateLastModified > dateadd("h", -24, Now) then 
        found = true
      end if 
    next 
    if (found = false) then
      SendEmail
    End If
    
    
    Function SendEmail() 
     'Send Email notification function here (this part works already)
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have maven-plagin and need to run goal, that should automatically run before plugin.
We're using the Maven exec:java goal to run a custom java application that configures
Goal: Produce an Excel document with information from 3 associated models that is similar
The goal is to run some tests given some data in those Xml files.
My goal is to run SVN commands from java for one of my requirements,
I'm going to need to push and pull files from a SharePoint site that
Basic Goal is that i have four progress bar and want to run them
The goal: run some functions on .ajaxStart() but only if fired by a certain
I'm trying to run exec-maven-plugin 's exec:java goal on a simple two-module project where
My final goal is to write the program which can run on the Unix

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.