Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 712
  • Last Modified:

Script to monitor scheduled task


I´m working on monitoring scheduled tasks in different windows servers. Is there any script that I can use to do this?
I´ve found an example but I´m not sure if it works because I don´t know the arguments.

Thanks for your help
Dim WshShell,oExec
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("schtasks /query /fo list /v")
strHold = oExec.StdOut.ReadAll
strHold = Replace(strHold,Chr(10),"<br> ")
WScript.Echo "Message:" & strHold
WScript.Echo "Statistic:0"

Open in new window

3 Solutions
This script works fine...

The output is html formatted.

execute the following modify vbscriptname.vbs to the script filename

cscript //nologo vbscriptname.vbs >schedtask.html

You can open the html file to see the output.
Bill PrewCommented:
What information do you want to see, and how do you want it presented?

Will you be processing a list of servers or individual servers?

Will you be running this on each server, or running from a central server and want to query the remote servers?

edit a file  copy the above  code and paste them in the file
rename  the file with .vbs extnsion
example create a file like sample.vbs and copy the contents in it
then jsu double click on the vbs file

it would get executed  automatically

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

andresskAuthor Commented:
Hi, thanks for your reply,

In fact, the script will be running from a central server and I want to query the remote servers.
The information that I want to see is the status of all the scheduled tasks that I have on all the remote servers, for example if a task execution was successful.
Bill PrewCommented:
Are you sure you want ALL scheduled tasks, on my Windows 7 desktop there are 77 scheduled tasks, nearly all of which are core Windows support jobs, not "user" jobs.  o you really want to weed through all those?

Feels like you might want some type of dashboard that highlighted the ones with a last run result of not 0.  But even at that a number of the Windows internal jobs often seem to have non zero status.

Would you have a text file that listed the servers to scan?

andresskAuthor Commented:
Hi billprew,

Thanks as always for your help.

You are right, the number of jobs is very high if I want to monitor all of them, and the load of the servers may be impacted.
Let me explain what I want to do:
We use Solarwinds APM to monitor our critical apps, and for those apps that don´t have specific processes or services, we use custom vb scripts that can be imported into the monitoring tool, such as the one of the example.

We have applications on 2 servers like Jboss that run only by *.bat files that are started all mornings by scheduled tasks, and those .bat processes can´t be monitored remotely one by one from the monitoring tool, we only see one process and can´t see the individual status. Directly on the server we can check the status of the jboss processes in the server with a cmd screen for every process (around 15). The fact is that we don´t know when a problem occurs on one process until it´s too late, and we have had a lot of problems because of that. So, the easiest way that we found is checking the scheduled tasks that run those .bat processes, but I don´t know if there´s is a more appropriate way of doing it.

There are 2 remote servers: one main server and one that is the backup.
andresskAuthor Commented:
No new replies. Found the the solution here at the company

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now