Search 85,941 posts and 653 resources contributed by 43,546 members or post a topic.

Already Joined? Sign in
How to run a VB script using Windows Scripting Monitor

Page 1 of 1 (2 items) | RSS

rated by 0 users
Not Answered This post has 0 verified answers | 1 Reply | 2 Followers | 567 Views


1 Posts
Points 3
tableau posted on Tue, Dec 9 2008 6:09 PM
rated by 0 users

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

  • | Post Points: 3

All Replies


1,000 Posts
Points 5,477
SolarWinds Certified Professional
Yann replied on Tue, Dec 16 2008 11:45 AM
rated by 0 users

Hi,

Windows Script Monitors are executed locally on the APM box, that might explain why your script does not work as it is checking the content of a local file that does not exist.

Does it help if you modify the objFSO.OpenTextFile line to:

objFSO.OpenTextFile("\\COMPUTERNAME\C$\dev\Watchman\tableau-1.3\src\unittest\db\testdata\Watchman\watchman-status.txt", 1)


Regards,

Yann

  • | Post Points: 1
Page 1 of 1 (2 items) | RSS

© 2003 - 2010 SolarWinds, Inc. All Rights Reserved.

Who is SolarWinds?

SolarWinds is rewriting the rules for how companies manage their networks. Guided by a global community of network engineers, SolarWinds develops simple and powerful network management software and network monitoring software for networks of all sizes. SolarWinds also offers a network certification program to become a SolarWinds Certified Professional (SCP).

What is thwack?

thwack, SolarWinds online community site, was designed by network engineers, for network engineers. thwack is a vibrant, growing community of more than 30,000 IT pros who share a passion for technology.

Explore Resources, Answers, Templates, and Advice

Download Free Networking Tools


Learn More About SolarWinds Products