Solved

vbscript add asynchronous and email to the script.

Posted on 2011-09-15
2
800 Views
Last Modified: 2012-05-12
Guys,

I have some issues in one server, some custom codes issues on SharePoint. For this reason everytime when the application pool down we saw the following error on the event viewer:

 
Event Type:	Error
Event Source:	W3SVC
Event Category:	None
Event ID:	1002
Date:		9/5/2011
Time:		5:46:48 PM
User:		N/A
Computer:	Server
Description:
Application pool 'Test_AppPool' is being automatically disabled due to a series of failures in the process(es) serving that application pool.

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

Open in new window


For this reason I found the following script to monitor some event on event viewer and when detect the error, up the application pool again.

I would like to add 2 thinks to this script but I need help how can I do it:

Make the script asynchronous to run everytime
After up the application pool start, send email with some message

This is the script:
Timeout= 30000
set events = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecNotificationQuery("select * from __instancecreationevent where targetinstance isa 'Win32_NTLogEvent' and TargetInstance.LogFile='System' and TargetInstance.EventCode=5002") 
Do
    WScript.Echo "==========================================================================="
    WScript.Echo "Listening for IIS Rapid Fail Protection Events"
    Set objLatestEvent = events.NextEvent
    Wscript.Echo objLatestEvent.TargetInstance.Message
    ' get the AppPool name from the Eventlog message

    appPool = objLatestEvent.TargetInstance.InsertionStrings(0)
    WScript.Echo "Restarting Application Pool '" & appPool & "' in " & Timeout & " milliseconds"
    WScript.Sleep(Timeout)

    'construct ADSI path to failed AppPool and start by setting AppPoolCommand to 1
    set pool = GetObject("IIS://localhost/w3svc/AppPools/" & appPool)
    pool.AppPoolCommand = 1
    pool.SetInfo
    WScript.Echo "AppPool " & appPool & " restarted"
    WScript.Echo "==========================================================================="
    WScript.Echo
Loop

Open in new window


Thanks in advance,
0
Comment
Question by:Gonzalo Becerra
2 Comments
 
LVL 63

Accepted Solution

by:
Zvonko earned 500 total points
ID: 36545974
To send messages use CDO.Message object: http:Q_20902249.html#10485940

0
 
LVL 1

Author Comment

by:Gonzalo Becerra
ID: 36548769
Thanks but how can I adapt before start the application pool send the email?.

How can I make as asynchronous to run everytime.
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need VBA code to change date format of Column A 5 30
Records from Access to Excel to specific cells 5 36
using vb script 5 47
vb.net deleting excel sheet in workbook 11 29
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

685 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