?
Solved

vbscript add asynchronous and email to the script.

Posted on 2011-09-15
2
Medium Priority
?
812 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 63

Accepted Solution

by:
Zvonko earned 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
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…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Suggested Courses

765 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