Customer Center

Welcome back

My Account Logout
#4732
Anonymous
Inactive

Scott:  While using the scheduler is certainly nice, what you are probably looking for is a "time out" you want to put in your script.  If nothing is going on for say 5 minutes, it calls the time out which stops the running script.  Then the next one in line can run.

Check out how to put an "on Timeout with a sub routine to run.

My ontimeout runs this
errorExit "script failed " 

—————————————-
ErrorExit has this:
Private Sub errorExit(outline As String, Optional scout As Integer)
On Error Resume Next
Key "@_close"                                       'close Meditech client

Dim theBody As String
Dim computerName As String: computerName = NameOfComputer()
theBody = outline & " and was reset"
theBody = theBody & " If this script continues to fail, we are having problems either with Meditech or the scripting server."
theBody = theBody & " The Script is running on server name " & computerName
theBody = theBody & " Please log onto server " & computerName & " double click on the BostonScripts folder on the desktop,"
theBody = theBody & " Then Double click on the stop.vbs file, this will stop all scripts running on the machine."
theBody = theBody & " It will take about 2 to 3 minutes to stop all the script and you will be prompted when it's complete."
theBody = theBody & " Then double click on the start_scripts.vbs file, this will start all scripts on this server."
theBody = theBody & " It will take 2 to 3 minutes to start all the scripts and you will be prompted with a message box when they are started."
  

SendMail "email address", outline, theBody, "email address", "", 

If scout = 1 Then

SendMail "email Address", outline, theBody, "email Address", "", 
 End If
    Wait 2                                              'wait for the e-mail

D.Close_
KillAll "T.exe"                                                 'exits the script
End                                                     'exits the script

End Sub

This is old code and could be better.
*****************************************************************************
3 important pieces to this code;

Key "@_close"                                       'close Meditech client
D.Close_

KillAll "T.exe"                                                 'exits the script
  The kill all is another sub that really just killes t.exe from the system ( it's insurance to make sure things died)

All the other code is pretty much sending an email

———————————————————–
KillAll code 
Sub KillAll(ProcessName As String)
    Dim objWMI
    Dim objServices
    Dim objservice
    Set objWMI = GetObject("winmgmts:")
    Set objServices = objWMI.instancesof("win32_process")
    For Each objservice In objServices
        'Debug.Print objservice.Name
        If UCase(objservice.Name) = UCase(ProcessName) Then
            objservice.terminate
        End If
   Next
End Sub