Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


notification

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,53812
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> notification
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 notification - 11/26/2007 2:57:19 AM   
  abenitez77

 

Posts: 5
Score: 0
Joined: 10/8/2007
Status: offline
I have several jobs that run (scheduled windows jobs, MS SQL 200 DTS scheduled jobs).  I want to run a script that will tell me if any of the sceduled jobs have failed.  How can i do this?
 
 
Post #: 1
 
 RE: notification - 11/26/2007 2:38:16 PM   
  dm_4ever


Posts: 2635
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
Have you taken a look at schtasks which is available on WinXP and greater? It allows you to query scheduled task on local and remote machines and it will show you the last run time and  last result code (0 if successful).

I'd suggest you play with finding the correct syntax for it and then output to a text file or read it directly using the shell object.  Some parsing will be necessary, but get started with that and post what you have so we can help you achieve your goal.

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to abenitez77)
 
 
Post #: 2
 
 RE: notification - 11/26/2007 3:40:07 PM   
  abenitez77

 

Posts: 5
Score: 0
Joined: 10/8/2007
Status: offline
I have this but I get nothing, not even an error msg.  I even tried running it locally on the server.

strComputer = "usman01srfs04"
Dim StrMsg
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colScheduledJobs = objWMIService.ExecQuery _
("SELECT * FROM Win32_ScheduledJob")
For Each objJob in colScheduledJobs
StrMsg = StrMsg & "Caption: " & objJob.Caption & vbCrLf _
    & "Command: " & objJob.Command & vbCrlf _
   & "Days Of Month: " & objJob.DaysOfMonth & vbCrlf _
   & "Days Of Week: " & objJob.DaysOfWeek & vbCrlf _
   & "Description: " & objJob.Description & vbCrlf _
   & "Elapsed Time: " & objJob.ElapsedTime & vbCrlf _
   & "Install Date: " & objJob.InstallDate & vbCrlf _
   & "Interact with Desktop: " & objJob.InteractWithDesktop & vbCrlf _
   & "Job ID: " & objJob.JobID & vbCrlf _
   & "Job Status: " & objJob.JobStatus & vbCrlf _
   & "Name: " & objJob.Name & vbCrlf _
   & "Notify: " & objJob.Notify & vbCrlf _
   & "Owner: " & objJob.Owner & vbCrlf _
   & "Priority: " & objJob.Priority & vbCrlf _
   & "Run Repeatedly: " & objJob.RunRepeatedly & vbCrlf _
   & "Start Time: " & objJob.StartTime & vbCrlf _
   & "Status: " & objJob.Status & vbCrlf _
   & "Time Submitted: " & objJob.TimeSubmitted & vbCrlf _
   & "Until Time: " & objJob.UntilTime
   Wscript.Echo StrMsg
Next

(in reply to dm_4ever)
 
 
Post #: 3
 
 RE: notification - 11/26/2007 4:05:52 PM   
  dm_4ever


Posts: 2635
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
quote:


The Win32_ScheduledJob WMI class represents a job created with the AT command. The Win32_ScheduledJob class does not represent a job created with the Scheduled Task Wizard from the Control Panel. You cannot change a task created by WMI in the Scheduled Tasks UI.


Like I said...take a look at schtasks....i.e. SCHTASKS /QUERY /FO LIST /V /S ComputerName

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to abenitez77)
 
 
Post #: 4
 
 RE: notification - 11/27/2007 8:08:44 AM   
  abenitez77

 

Posts: 5
Score: 0
Joined: 10/8/2007
Status: offline
Thanks...I ran SCHTASKS /QUERY /FO LIST /V /S ComputerName > c:\tasks.txt

It exported all my tasks to a txt file.  I want to have a script I can run that will only show me the jobs that failed from my 3 servers that have scheduled tasks.  I don't want to go thru the text files every day to find out there were no failed jobs.  Is it possible to get a script to display just the failed jobs from the txt files?

output from schtasks command:

HostName:                             usman01srfs04
TaskName:                             HYE_CLAIMS
Next Run Time:                        19:10:00, 11/27/2007
Status:                              
Last Run Time:                        19:10:00, 11/26/2007
Last Result:                          0
Creator:                              abenit01
Schedule:                             At 7:10 PM every Mon, Tue, Wed, Thu, Fri of every week, starting 10/3/2007
Task To Run:                          E:\Scans\CopyExe\HYE_CLAIMS.bat
Start In:                             E:\Scans\CopyExe
Comment:                              N/A
Scheduled Task State:                 Enabled
Scheduled Type:                       Weekly
Start Time:                           19:10:00
Start Date:                           10/3/2007
End Date:                             N/A
Days:                                 MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY
Months:                               N/A
Run As User:                          AMER\SvcMan01Replication
Delete Task If Not Rescheduled:       Disabled
Stop Task If Runs X Hours and X Mins: 24:0
Repeat: Every:                        Disabled
Repeat: Until: Time:                  Disabled
Repeat: Until: Duration:              Disabled
Repeat: Stop If Still Running:        Disabled
Idle Time:                            Disabled
Power Management:                     No Start On Batteries, Stop On Battery Mode

(in reply to dm_4ever)
 
 
Post #: 5
 
 RE: notification - 11/27/2007 9:26:15 AM   
  dm_4ever


Posts: 2635
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
Sure it is possible to create a script like the one you mentioned, but you need to start before we can help.  Look at FileSystemObject to read the file from within a script and WSHShell to execute that command you came up with.

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to abenitez77)
 
 
Post #: 6
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> notification Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts