Solved

vbscript add asynchronous and email to the script.

Posted on 2011-09-15
2
798 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

831 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