Return exit status of console application run as scheduled task

J

John Williams

VB .Net 2003, .Net Framework 1.1, Windows XP Pro SP1

I've written a console application which I run as a scheduled task. How do
I return an exit status value (or string) from the application so that the
status is displayed in the Status column of the Scheduled Tasks window?

I've tried the following methods, and the console app definitely runs (as
shown by the Last Run Time in the Scheduled Tasks window), however the
Status column is blank.

Sub Main()
Dim ExitStatus As Integer = 10
Environment.ExitCode = ExitStatus
Environment.Exit(ExitStatus)
End Sub

Function Main() As Integer
Dim ExitStatus As Integer = 10
Return ExitStatus
End Function

Thanks for any help or info on this.
 
J

John Williams

John Williams said:
VB .Net 2003, .Net Framework 1.1, Windows XP Pro SP1
I've tried the following methods, and the console app definitely runs (as
shown by the Last Run Time in the Scheduled Tasks window), however the
Status column is blank.

The exit code returned is actually shown in the Last Result column. Maybe
the Status is there for the Task Scheduler to set and cannot be set directly
by the application?
 
T

Tom Shelton

The exit code returned is actually shown in the Last Result column. Maybe
the Status is there for the Task Scheduler to set and cannot be set directly
by the application?

I believe the status column will tell you if the application is running
or not... In other words, if you open the task sheduler while that
application is running, the status column will say Running.
 
J

John Williams

Tom Shelton said:
I believe the status column will tell you if the application is running
or not... In other words, if you open the task sheduler while that
application is running, the status column will say Running.

Thanks for your reply, Tom. I understand what the Status column does now.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top