Solved

vbscript add asynchronous and email to the script.

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Vbscript 8 78
excel file 5 65
VBS Script not working correctly. 1 37
problems with mysql ODBC Connector and vbscript 4 23
I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
The viewer will learn how to count occurrences of each item in an array.
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 …

932 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

8 Experts available now in Live!

Get 1:1 Help Now