Dim p As New Process
p.StartInfo.FileName = "path to my exe"
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
p.StartInfo.CreateNoWindow = True
Try
p.Start()
p.WaitForExit()
Catch ex As Exception
PIMessage = ex.Message
EmailSubject = "Error Running Scheduler"
EmailMessage = "Error running Scheduler. " & ex.Message
EmailAlert()
Finally
EmailSubject = "MyProgramName"
EmailMessage = "MyProgramName reports Exit Code = " & p.ExitCode & " at " & p.ExitTime
EmailAlert()
PIMessage = "Exit Code = " & p.ExitCode & " at " & p.ExitTime
p.Close()
End Try
Private Sub EmailAlert()
Dim myEmail As New MailMessage()
myEmail.From = New MailAddress("email@myemail.com")
myEmail.To.Add("me@myemail.com")
myEmail.Subject = EmailSubject
myEmail.Body = EmailMessage
myEmail.Priority = MailPriority.High
Dim smtp As New SmtpClient("mysmtpclient")
smtp.Send(myEmail)
End Sub
the executable need to report if success or failed.
does the exe need to get parameters?
to whom the exe need to notify if succeed or failed?
do u need to run the task scheduler only one time, in a specific time or every predefined date time?
does the exe write to log file upon success or failure?