I have a script that hangs when running as a scheduled task. It runs fine if I simply double-click the script. Script is scheduled to run as the logged on user. I simply cannot find the issue. It will run forever if I right click on it in Task Scheduler and wsript.exe uses 50% of the CPU. This is on a fully patch W7 machine. I have several other scripts that run fine. This is the only on with a Do Until routine though. If you cannot access the doc on SkyDrive let me know and I will hand write anything you need about Properties of task.
Thanks everyone.
Full script and permission here
'****** Script created 12-16-13 by Jeremy Frieburg ******'****** The purpose of this script is to search for the datascr.log file******
'****** used by Connection and parse it to make sure the******
'****** busey.zip.pgp entry exists, meaning the files have been successfully******
'****** uploaded to FIS. If not, then report error for manual intervention.******
On Error Resume Next
'----------------------------------------------------------------------------
'Specify variable for emails
'----------------------------------------------------------------------------
strScriptServer = "ASFOXTECHOPS01"
strScriptPath = "\\ASFOXTECHOPS01\C$\scripts\"
strScriptName = "[CONN-02]-Connections Upload Error Check"
'strToEmail = ""
strToEmail = ""
strCCEmail = ""
strCCEmailFail = ""
strProcessID = "[CONN-02]"
strCustomerImpact = "LOW"
strCorporateImpact = "HIGH"
strDocumentation = "\\FSCHAFOX01\GROUP_SHARE\Tech Group\Documentation\Automation\"
'----------------------------------------------------------------------------
Dim objFile, searchstring1, searchstring2, searchstring3, objLogFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objMessage = CreateObject("CDO.Message")
Set objShell = WScript.CreateObject("WScript.Shell")
objLogFile = "K:\Connections\MSI Upload Program\datascr.log"
search1 = "busey.zip.pgp"
search2 = "ftpuser"
search3 = Day(date)
bFound = False
Set objFile = objFSO.OpenTextFile(objLogFile,1)
'****** Parse the datascr.log file and look to see if it contains ftpuser and busey.zip.pgp strings ******'
Do until objFile.AtEndOfStream
strSearchString = objFile.ReadLine()
If InStr(strSearchString, search1) <> 0 and InStr(strSearchString, search2) <> 0 and InStr(strSearchString, search3) <> 0 Then
bFound = True
'WScript.echo "Found"
End If
Loop
objFile.Close
If Err <> 0 Then
HandleError
End If
if bFound = True Then
'Send Results email
objMessage.Subject = "SUCCESS - " & strProcessID & " - Connections Files Successfuly Uploaded to FIS"
objMessage.From = "IT Automation"
objMessage.Sender = "automation@busey.com"
objMessage.To = strToEmail
objMessage.Cc = strCCEmail
objMessage.TextBody = "---------------SCRIPT SUCCESSFUL---------------" & vbnewline & VbCrLf & "Connections files have been uploaded with no errors." & vbnewline & vbcrlf & "- Script Name:" & VbTab& VbTab & strScriptName & VbNewLine & VbCrLf & "- Script Origination:" & VbTab & VbTab & strScriptServer & VbNewline & VbCrLf & "- Script Path:" & VbTab & VbTab & VbTab & strScriptPath& VbNewLine & VbCrLf & "- Documentation:" & VbTab & VbTab & strDocumentation & VbNewLine & VbCrLf & "------------------------------------------------------------"
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.firstbusey.corp"
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update
objMessage.Send
'wscript.echo "Sent"
Else
HandleError
End If
Sub HandleError
strErrorMessage = "Error Number " & Err.Number & ":" & Err.Description
objMessage.Subject = "SCRIPT ERROR - " & strProcessID & " - IMMEDIATE ACTION REQUIRED"
objMessage.From = "IT Automation"
objMessage.Sender = "automation@busey.com"
objMessage.To = strToEmail
objMessage.Cc = strCCEmail & ";" & strCCEmailFail
objMessage.TextBody = "---------------SCRIPT ERROR---------------" & vbnewline & VbCrLf & "The Connections files have not been successfully sent to FIS. Manual intervention required." & vbnewline & VbCrLf& "Script Name:" & VbTab & VbTab & VbTab & strScriptName & VbNewLine & VbCrLf & "Customer Impact:" & VbTab & VbTab & VbTab & strCustomerImpact & VbNewLine & VbCrLf & "Corporate Impact:" & VbTab & VbTab & VbTab & strCorporateImpact & VbNewLine & VbCrLf & "Error Description:" & VbTab & VbTab & VbTab & Err.Description & vbnewline & VbCrLf & "Error Number:"& VbTab & VbTab & VbTab & Err.Number & VbCrLf & VbNewLine & "Script Location:" & VbTab & VbTab & VbTab & strScriptServer & VbCrLf & VbNewLine & "Script Path:" & VbTab & VbTab& VbTab & strScriptPath & VbNewline & VbCrLf & "- Documentation:" & VbTab & VbTab & strDocumentation & VbNewLine & VbCrLf & "-------------------------------------------------"
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.firstbusey.corp"
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update
objMessage.Send
Err.Clear
End Sub