+ Post New Thread
Results 1 to 2 of 2
Scripts Thread, Script to run automaticly in Coding and Web Development; I have the following script.... ----------------------------------------------------------------- Set objComputer = GetObject("WinNT://computername,computer") objComputer.Filter = Array("Service") strServiceName = "MYSERVICE" For Each aService In ...
  1. #1
    Newton's Avatar
    Join Date
    Oct 2007
    Posts
    179
    Thank Post
    59
    Thanked 5 Times in 5 Posts
    Rep Power
    9

    Script to run automaticly

    I have the following script....
    -----------------------------------------------------------------
    Set objComputer = GetObject("WinNT://computername,computer")
    objComputer.Filter = Array("Service")

    strServiceName = "MYSERVICE"

    For Each aService In objComputer
    If LCase(strServiceName) = LCase(aService.Name) Then
    if aService.Status = 1 then
    'Service stopped so start it
    aService.start
    end if
    End If
    Next
    ------------------------------------------------------------------
    All it does is check for a service and if its stopped start it.

    I'd like to check the status every X minutes (say 15 for now) automaticly how would you recommend going about this, something self contained in the script would be ideal

    something like
    do
    'sleep15minutes check service
    loop

    or
    as a scheduled task??
    Last edited by Newton; 18th June 2009 at 03:45 PM.

  2. #2

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,110
    Blog Entries
    2
    Thank Post
    110
    Thanked 511 Times in 443 Posts
    Rep Power
    114
    You can configure a scheduled task to run every 15 minutes - just look in the advanced properties of task scheduler - but why do you want to do this?

    If you look at the properties of the service in service manager you'll see a "what to do if the service stops" and there's a load of things, including restart it.

    You can also specify what to do it it stops more than once so you could have "restart" on first and second failure but "run a program" on the third - that program could send an email to you to alert you to trouble.

    You can also control how long the count lasts for (ie it isn't "first ever failure" but "first failure in 15 minutes" or whatever you choose)

SHARE:
+ Post New Thread

Similar Threads

  1. Run script if specific hardware present
    By djones in forum Scripts
    Replies: 7
    Last Post: 14th March 2008, 04:50 PM
  2. Need a script to run programs
    By timbo343 in forum Scripts
    Replies: 9
    Last Post: 26th September 2007, 12:24 PM
  3. Run Script as Administrator
    By TSCNUK in forum Windows
    Replies: 8
    Last Post: 20th November 2006, 05:20 PM
  4. Run script with elevated permissions
    By ajbritton in forum Windows
    Replies: 3
    Last Post: 9th August 2006, 02:04 PM
  5. One PC refuses to run script! Help!!!
    By woody in forum Scripts
    Replies: 6
    Last Post: 5th October 2005, 11:37 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •