1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

newbie to VB scripting

Discussion in 'Software Development' started by scutch2222, Jul 19, 2007.

Thread Status:
Not open for further replies.
Advertisement
  1. scutch2222

    scutch2222 Thread Starter

    Joined:
    Sep 11, 2003
    Messages:
    271
    I do not have much of a background in programing but I needed to know how it would be possible to use VB scripting to send a alert ( via email or net send message ) when a log file grows to a certain point. This log file lives in a windows 2000 server enviroment. Should I learn this from scratch and is there any good url's to check out, how long would it take me to achieve this. Or can I simply access a use a script that has this done already, and I would just tweak it to my needs. Sorry if this sounds stupid ... I am just having trouble knowing where to start. Thanks in advance
     
  2. Mosaic1

    Mosaic1

    Joined:
    Aug 17, 2001
    Messages:
    7,486
    Two steps. You want to monitor the size of the file, or have you already done this?

    Then if it gets to a certain size, you want to use net send to alert to the situation? But if the Messenger Service is turned off on the system you want to alert, they won't get the message.
     
  3. scutch2222

    scutch2222 Thread Starter

    Joined:
    Sep 11, 2003
    Messages:
    271
    I do need to monitor the size of the file , I only do this when I manually go to the server to check ( which of course I can not do this every day or night). So I do need something automated to monitor the size of the file. I do understand if the service is turned off then it is useless. I will make sure that service is running .
     
  4. ghostdog74

    ghostdog74

    Joined:
    Dec 7, 2005
    Messages:
    146
    monitoring code:
    Code:
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.GetFile("C:\logfile")
    If objFile.Size > 119 Then    
        Wscript.Echo "File sizes over 119 bytes..sending email now"    
        'Set objEmail = CreateObject("CDO.Message")
        'objEmail.From = "[email protected]"
        'objEmail.To = "[email protected]" 
        'objEmail.Subject = "Atl-dc-01 down" 
        'objEmail.Textbody = "Atl-dc-01 is no longer accessible over the network."
        'objEmail.Send
        'OR use net send
        Set Shell = CreateObject("Wscript.Shell")
        Name = "name"
        MSG = "message"
        SHELL.Run "Net Send " & Name & " " & MSG, 0, False
    End If
    
     
  5. scutch2222

    scutch2222 Thread Starter

    Joined:
    Sep 11, 2003
    Messages:
    271
    Thank you very much ghostdog, much appreciated , I will keep you apprised
     
  6. Mosaic1

    Mosaic1

    Joined:
    Aug 17, 2001
    Messages:
    7,486
    I see someone else has answered in the meantime. You can also remove the commented lines. Any line beginning with a ' is not read by the script. These lines would be used to send a message by email as another option.

    My question is how to run htis script? It only runs once and then ends. It is not monitoring in the background. What did you want to do?

    If you want to monitor constantly, you would add a script as a startup. WMI has a class to handle file monitoring. That new script would run in the background constantly.

    Next, did you want it to shut down if it finds the log size limit has been reached and after sending the message?

    The other choice would be to run this script posted here in a loop, and shut it down after sending the message. But that may eat up a bit more memory than you might like. It would have to be tested.
     
  7. ghostdog74

    ghostdog74

    Joined:
    Dec 7, 2005
    Messages:
    146
    the script can be run by the task scheduler, effectively serving the purpose of monitoring in the background.
     
  8. Mosaic1

    Mosaic1

    Joined:
    Aug 17, 2001
    Messages:
    7,486
    Yes. It could be. There might be several solutions. Running as a task is one good one. But monitoring constantly would require more. How often do you run the task? And then how many alerts would be sent etc?

    I guess I wanted to see how this log was created etc. Would it be possible to rename the log and move it to a holding location if it is over a certain size and create a fresh new one automatically? And then send the alert or an email? Could you then just check the folder for old logs etc. when you have the chance?

    Automating has advantages.
     
  9. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/597790

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice