Script to monitor scheduled task

Posted on 2011-04-20
Last Modified: 2012-05-11

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

Question by:andressk
    LVL 12

    Accepted Solution

    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.
    LVL 51

    Expert Comment

    by:Bill Prew
    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?

    LVL 2

    Assisted Solution

    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


    Author Comment

    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.
    LVL 51

    Assisted Solution

    by:Bill Prew
    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?


    Author Comment

    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.

    Author Closing Comment

    No new replies. Found the the solution here at the company

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
    Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    733 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

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now