?
Solved

Can you dynamically program a windows task scheduler?

Posted on 2013-11-06
7
Medium Priority
?
584 Views
Last Modified: 2013-12-18
My workgroup has a series of Access macros/reports that run each day with the help of windows task scheduler. Most of the files being imported each day maintain the same name.

Is there a way to program the scheduler to run when the Date Modified property is updated?
0
Comment
Question by:Dominator1025
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 14

Expert Comment

by:Bill Ross
ID: 39629926
Hi,

I would write a DOS batch file that checks the file date and runs access /macros if the file date is changed.  It will take some research but you can use an if statement.

Run the batch file each hour or whatever using the event scheduler.

Regards,

Bill
0
 
LVL 26

Expert Comment

by:Nick67
ID: 39630911
Is there a way to program the scheduler to run when the Date Modified property is updated

Not per se.
The scheduler runs on a time basis, period.
Now, a VBScript that checks the files you have in mind, checks to see if Access is open, and if the files have changed and Access is not running, fires up Access to do the rest could be written.  It then can be scheduled to run very frequently.

But the task scheduler itself, that gets set off strictly by a time event.
0
 
LVL 3

Expert Comment

by:0Doc
ID: 39631037
Create a VB script that that checks if files have been modified.  In the script, if a modified file is detected, then launch the task scheduler.  This can be done with the SCHTASKS command.  Something like SCHTASKS /Run /TN <my scheduled tasks>.

I hope this helps,

0doc
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 56

Expert Comment

by:McKnife
ID: 39631877
@Nick67
> The scheduler runs on a time basis, period.
That's wrong. Starting with windows xp we could trigger tasks on event creation. With Vista/7/8/8.1 this is even GUI driven possible (with xp there was eventtriggers.exe).

That said: you could setup ntfs auditing on that file. Whenever it gets changed, an event would get created in the security event log and that event can be attached to your task.
0
 
LVL 14

Expert Comment

by:Bill Ross
ID: 39631896
Hi,

Back to my original comments - use the task scheduler to run the test process at an interval, say hourly,  and execute if file date is updated.  Process can be any scripting language.

Regards,

Bill
0
 
LVL 26

Expert Comment

by:Nick67
ID: 39631916
Options
Neat enough.  Here are the full list of things that can set off a task in Win 7.
Perhaps the only fly in the ointment of doing it through auditing and the event log is that the Access process may also trip the auditing and set off the task again.  But then, that depends very much upon other options (don't run this task if it is already running) and what code you make the task do.

But @McKnife, you were right, time isn't the only trigger by a long shot.
Thanks,

Nick67
0
 
LVL 25

Accepted Solution

by:
SStory earned 2000 total points
ID: 39633328
You could forget the scheduler and write a VB.NET app or service that will have a FileSystemWatcher. It could watch for file changes and evaluate them.

Here is an example from MSDN

    ' Create a new FileSystemWatcher and set its properties. 
        Dim watcher As New FileSystemWatcher()
        watcher.Path = args(1)
        ' Watch for changes in LastAccess and LastWrite times, and 
        ' the renaming of files or directories. 
        watcher.NotifyFilter = (NotifyFilters.LastAccess Or NotifyFilters.LastWrite Or NotifyFilters.FileName Or NotifyFilters.DirectoryName)
        ' Only watch text files.
        watcher.Filter = "*.txt" 

        ' Add event handlers. 
        AddHandler watcher.Changed, AddressOf OnChanged
        AddHandler watcher.Created, AddressOf OnChanged
        AddHandler watcher.Deleted, AddressOf OnChanged
        AddHandler watcher.Renamed, AddressOf OnRenamed

        ' Begin watching.
        watcher.EnableRaisingEvents = True

Open in new window

(source: http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx)

Here is another example of using it:
http://www.codeproject.com/Articles/3192/Watching-Folder-Activity-in-VB-NET

You could get enough info from these two to build it.  The one from MSDN appears to do exactly what you want and more.  Then you'd just leave that program or better service always running to take care of this.

The following shows you how to create a Windows service:
http://msdn.microsoft.com/en-us/library/zt39148a%28v=vs.110%29.aspx

Just remember that it can have no user interaction.
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question