Solved

vbscript add asynchronous and email to the script.

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

705 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

18 Experts available now in Live!

Get 1:1 Help Now