Hi,
I've created a custom application using the Windows Scripting Monitor to run a vbscript, but it doesn't appear to be working. What I want to be able to do is read a text file on the remote machine and if one value is specified generate an email alert. To do this I've created a Windows Script Monitor, set the appropriate credentials (and tested them), and then plugged in the below script. Basically I just want APM to run the script on a regular basis. Is this the way I should go about it and/or is there a different way the script language needs to be entered? I've tested the script independently and it runs correctly.
Script:
Const ForReading = 1
numCount=0
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\dev\Watchman\tableau-1.3\src\unittest\db\testdata\Watchman\watchman-status.txt", 1)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
wscript.echo strLine
if strline="1" then
strBody= objFile.Readall
strEmail
End If
numCount=numCount+1
Loop
objFile.Close
Sub strEmail
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "my email address"
objEmail.To = "my email address"
objEmail.Subject = "Computer accounts deleted by script on " & Date
objEmail.Textbody = strBody
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "our email relay"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send
Wscript.echo "Email Sent"
End Sub