Link to home
Start Free TrialLog in
Avatar of NSheld
NSheld

asked on

perfmon will not execute a vbs script which in turn sends an email alert

Hi,
I have wrote a simple vbs script that sends an email whenh executed. This script works, so the problem is not with the script.
I am checking logicaldisk within perfmon, and set a test threshold so that it alerts me via the vbs email script.
Alas, the script never runs.
I have even tried changing it to a bat and cmd file by adding the cscript (the script works when executed manually).
I have tried running perfmon on Windows 2000 Server, and also Windows 2003 Server (I added a domain admin user to run the script), but the script never initializes
Is it possible to do this?
I googled this and found someone else with the exact same problem here:
http://www.webservertalk.com/message1429460.html

Cheers
Avatar of SteveGTR
SteveGTR
Flag of United States of America image

Can you wrap the vbs processing in a batch file and dump out some debugging information in the batch file to verify that the processing is being executed and also capture any errors generated from the vbs processing. Something like this. Also, you've only assigned 50 points for the question. You'll get better responses by awarding a more suitable value to the question. In this case I'd recommend 250 or 500.
@echo off
 
setlocal
 
set outFile=c:\temp\temp.log
 
echo In %~0 %date% %time%>>"%outFile%"
 
cscript c:\yourdir\script.vbs >>"%outFile%" 2>&1 

Open in new window

Avatar of giltjr
Do you see any errors in any of the event logs?

What user-id are you attempting to execute the script under?  Does this user-id have execute authority for your script file?

If you create a batch file that does something like:

echo STARTED > c:\log1.txt
cscript c:\pathtoscript\script.vbs or just plain c:\pathtoscript\script.vsb
echo ENDED >> c:\log1.txt

Do you get anything in log1.txt?
While I'm not very versed in this stuff... it's my understanding that in order to receive an email alert for a performance monitor alert, the alert needs to create an entry in the event log, and the email is sent due to the event log entry being created.  This process uses the eventtriggers command.

If your alert is not already creating the event, see this KB for how to get it to do that:  http://support.microsoft.com/kb/184747

Then, in order to send an email from an event, you need to create a script as follows (my example is for Event ID 1016):

Save the following script in C:\batch with the name 1016.vbs

'begin code
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Drive Space"
objMessage.From = "administrator@domain.com"
objMessage.To = "someaddress@domain.com"
objMessage.TextBody = "Drive Space Warning"
objMessage.Send
'end code

Change the addresses in 1016.vbs to match your domain (leave the administrator but change the domain name in the objMessage.From), and the real address where you want the email to be sent (objMessage.To).

Test the script to make sure that it sends the email for you.

Finally, you must use the eventtriggers command to create the trigger:

Enter the following at a Command Prompt:

eventtriggers /create /tr DriveSpaceWarn /eid 1016 /t INFORMATION /tk "c:\batch\1016.vbs" /ru "System"

More info on eventtriggers:  http://technet2.microsoft.com/windowsserver/en/library/e33bcf4c-dece-4b47-9bb7-31ecfcbc76d51033.mspx?mfr=true

Jeff
TechSoEasy


ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial