Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

vb update

Avatar of B0b_shiska
B0b_shiska asked on
ProgrammingVB Script
3 Comments1 Solution324 ViewsLast Modified:
Hello. i have a script that watches a constantly updating xml file for inactivity. At the moment, the script will send an email if the file has not updated in x time. Since the script will be running constantly, are there are performance enhancements or modifications that can be carried out on the script? Thanks in advance.

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colFiles = objWMIService.ExecQuery _
    ("Select * from CIM_Datafile Where Name = 'C:\\programfiles\\filepath\\name.xml'")

For Each objFile in colFiles
    strOriginalTimestamp = objFile.LastModified
Next

Do While True
    Wscript.Sleep 3600000
    Set colFiles = objWMIService.ExecQuery _
        ("Select * from CIM_Datafile Where Name = 'C:\\programfiles\\filepath\\name.xml'")

    For Each objFile in colFiles
        strLatestTimestamp = objFile.LastModified
    Next

Set objEmail = CreateObject("CDO.Message")

On Error Resume Next    
   ProcessScript
    If strLatestTimestamp <> strOriginalTimestamp Then
        strOriginalTimestamp = strLatestTimeStamp
    Else
        objEmail.Subject = "emailsubject."
    objEmail.From = "123@name.com"
    objEmail.To = "abc@xyz.com"
    objEmail.TextBody = ("text.")
    objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "servername"
    objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = #
    objEmail.Configuration.Fields.Update
    objEmail.Send
   End If    
Loop
ASKER CERTIFIED SOLUTION
Avatar of ptessels
ptesselsFlag of Netherlands image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answers