I want to run a VBScript through Windows Server 2000's scheduled task. On
failing to execute certain task within the script, I want the job to show up
as "Failed" with a result of 1 on the Scheduled Task list. How could this
be done?

"Return 1" does nott work. Even when 1 is returned, the "Last Result" still
show up as 0x0.

Re: Returning Error Code by Torgeir

Torgeir
Tue Jan 20 08:30:43 CST 2004

Patrick wrote:

> I want to run a VBScript through Windows Server 2000's scheduled task. On
> failing to execute certain task within the script, I want the job to show up
> as "Failed" with a result of 1 on the Scheduled Task list. How could this
> be done?
>
> "Return 1" does nott work. Even when 1 is returned, the "Last Result" still
> show up as 0x0.

Hi

Have you tried

WScript.Quit 1


--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter



RE: Returning Error Code by v-wdxu

v-wdxu
Wed Jan 21 01:20:11 CST 2004

Hi Patrick,

From my understanding to your issue, you want to display one "1" as the
return code for your vbscript task.

I agree with Torgeir. If you use the "WScript.quit 1", the return code will
be displayed as "0x1" which will be usfule for your scenario.

Please feel free to let me know if you have any further questions.

Does this answer your question? Thank you for using Microsoft NewsGroup!

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.


Re: Returning Error Code by Patrick

Patrick
Wed Jan 21 09:39:02 CST 2004

How could I get thee VBScript to show up as "Failed" on the scheuled task
list also?

"Wei-Dong Xu [MSFT]" <v-wdxu@online.microsoft.com> wrote in message
news:RTl6M8%233DHA.1512@cpmsftngxa07.phx.gbl...
> Hi Patrick,
>
> From my understanding to your issue, you want to display one "1" as the
> return code for your vbscript task.
>
> I agree with Torgeir. If you use the "WScript.quit 1", the return code
will
> be displayed as "0x1" which will be usfule for your scenario.
>
> Please feel free to let me know if you have any further questions.
>
> Does this answer your question? Thank you for using Microsoft NewsGroup!
>
> Wei-Dong Xu
> Microsoft Product Support Services
> Get Secure! - www.microsoft.com/security
> This posting is provided "AS IS" with no warranties, and confers no
rights.
>



Re: Returning Error Code by Michael

Michael
Wed Jan 21 20:50:18 CST 2004

Patrick wrote:
> How could I get thee VBScript to show up as "Failed" on the scheuled
> task list also?


I doubt it. The task scheduler has no way to interpret the meaning of exit
codes. There is no reason a non-zero exit code necessarily means failure
from the task scheduler's perspective. Failed is probably used only when the
task won't start for some reason (e.g., bad target executable path, bad
account credentials, etc.) which the scheduler can clearly interpret that as
a failure.


--
Michael Harris
Microsoft.MVP.Scripting

Windows 2000 Scripting Guide
Microsoft® Windows®2000 Scripting Guide
http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overview.asp

TechNet Script Center Sample Scripts
http://www.microsoft.com/downloads/release.asp?ReleaseID=38942

WSH 5.6 documentation download
http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en


Re: Returning Error Code by michmo

michmo
Fri Jan 23 16:17:47 CST 2004

Hi Patrick,

I apologize for the delay in replying. We are still researching this issue
and will post more information as soon as we can.

Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computer?s security.

This posting is provided "AS IS", with no warranties, and confers no rights.

--------------------
> From: "Patrick" <patl@reply.newsgroup.msn.com>
> References: <ulkViW03DHA.3360@tk2msftngp13.phx.gbl>
<RTl6M8#3DHA.1512@cpmsftngxa07.phx.gbl>
> Subject: Re: Returning Error Code
> Date: Wed, 21 Jan 2004 15:39:02 -0000
> Lines: 26
> X-Priority: 3
> X-MSMail-Priority: Normal
> X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
> Message-ID: <#JmrzSD4DHA.1632@TK2MSFTNGP12.phx.gbl>
> Newsgroups: microsoft.public.scripting.vbscript
> NNTP-Posting-Host: host217-40-135-73.in-addr.btopenworld.com 217.40.135.73
> Path:
cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.
phx.gbl
> Xref: cpmsftngxa07.phx.gbl microsoft.public.scripting.vbscript:144664
> X-Tomcat-NG: microsoft.public.scripting.vbscript
>
> How could I get thee VBScript to show up as "Failed" on the scheuled task
> list also?
>
> "Wei-Dong Xu [MSFT]" <v-wdxu@online.microsoft.com> wrote in message
> news:RTl6M8%233DHA.1512@cpmsftngxa07.phx.gbl...
> > Hi Patrick,
> >
> > From my understanding to your issue, you want to display one "1" as the
> > return code for your vbscript task.
> >
> > I agree with Torgeir. If you use the "WScript.quit 1", the return code
> will
> > be displayed as "0x1" which will be usfule for your scenario.
> >
> > Please feel free to let me know if you have any further questions.
> >
> > Does this answer your question? Thank you for using Microsoft NewsGroup!
> >
> > Wei-Dong Xu
> > Microsoft Product Support Services
> > Get Secure! - www.microsoft.com/security
> > This posting is provided "AS IS" with no warranties, and confers no
> rights.
> >
>
>
>


Re: Returning Error Code by v-wdxu

v-wdxu
Mon Jan 26 03:31:50 CST 2004

Hi Patrick,

Thank you for replying!

From my understanding to this scenario, you want to check the failed
task(s) from the list view with the customized "Failed" string. This will
be very quick for you and the users to find the failed tasks.

However, based on my research, there is no way for us to modify the value
of status or Last result to "Failed" in the Schedule Task List view in
vbscript. Even in C++, the IScheduledWorkItem interface doesn't provide one
method to set the value. This interface is used to manage specific work
item of the task schedule. You will obtain more information regarding this
interface from the link:
IScheduledWorkItem
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/taskschd/ta
skschd/ischeduledworkitem.asp

My suggestion now is that you can develop one component to add some
specific comment in the work item, then you can build another component to
enumerate the work item for these specific comment and then give one
report. You can use the SetComment/GetComment method of the
IScheduledWorkItem interface to operate the comment. This way, you can call
the component directly in the vbscript and check the report for these
failed tasks.

There are severals samples for operating the work items of task schedules
from MSDN.Microsoft.com which may be very helpful for you concerning this
issue.
C/C++ Code Example: Setting Task Comment
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/taskschd/ta
skschd/c_c_code_example_setting_task_comment.asp

C/C++ Code Example: Enumerating Tasks
http://msdn.microsoft.com/library/en-us/taskschd/taskschd/c_c_code_example_e
numerating_tasks.asp

Please feel free to let me know if you have any further questions. I am
standing by to be of assistance.

Does this answer your question? Thank you for using Microsoft NewsGroup!

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.


Re: Returning Error Code by Patrick

Patrick
Wed Jan 28 03:24:48 CST 2004

I have accepted defeat that it would be difficult/impossible to return
"failed status" to scheduled task from a VBScript.
"Wei-Dong Xu [MSFT]" <v-wdxu@online.microsoft.com> wrote in message
news:6XZst8%234DHA.568@cpmsftngxa07.phx.gbl...
> Hi Patrick,
>
> Thank you for replying!
>
> From my understanding to this scenario, you want to check the failed
> task(s) from the list view with the customized "Failed" string. This will
> be very quick for you and the users to find the failed tasks.
>
> However, based on my research, there is no way for us to modify the value
> of status or Last result to "Failed" in the Schedule Task List view in
> vbscript. Even in C++, the IScheduledWorkItem interface doesn't provide
one
> method to set the value. This interface is used to manage specific work
> item of the task schedule. You will obtain more information regarding this
> interface from the link:
> IScheduledWorkItem
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/taskschd/ta
> skschd/ischeduledworkitem.asp
>
> My suggestion now is that you can develop one component to add some
> specific comment in the work item, then you can build another component to
> enumerate the work item for these specific comment and then give one
> report. You can use the SetComment/GetComment method of the
> IScheduledWorkItem interface to operate the comment. This way, you can
call
> the component directly in the vbscript and check the report for these
> failed tasks.
>
> There are severals samples for operating the work items of task schedules
> from MSDN.Microsoft.com which may be very helpful for you concerning this
> issue.
> C/C++ Code Example: Setting Task Comment
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/taskschd/ta
> skschd/c_c_code_example_setting_task_comment.asp
>
> C/C++ Code Example: Enumerating Tasks
>
http://msdn.microsoft.com/library/en-us/taskschd/taskschd/c_c_code_example_e
> numerating_tasks.asp
>
> Please feel free to let me know if you have any further questions. I am
> standing by to be of assistance.
>
> Does this answer your question? Thank you for using Microsoft NewsGroup!
>
> Wei-Dong Xu
> Microsoft Product Support Services
> Get Secure! - www.microsoft.com/security
> This posting is provided "AS IS" with no warranties, and confers no
rights.
>



Re: Returning Error Code by v-wdxu

v-wdxu
Wed Jan 28 18:51:58 CST 2004

Hi Patrick,

Thank you for replying!

This is the first time for me to think about adding one customized string
to the status in Task Schedule List view which will display some helpful
information for the users. After my research, I suddenly realized this is a
great idea for a future product enhancement for Task Schedule. We may
provide more methods for the display customer-defined information which
make the Task Schedule more useful. I'd recommend that you forward the
recommendation to the Microsoft Wish Program:
1. World Wide Web
a)In Internet Explorer 6, click Send Feedback on the Help menu and then
click the link in the Product Suggestion section of the page that appears.
b)In Windows XP, click Help and Support on the Start menu. Click Send
your feedback to Microsoft, and then fill out the Product Suggestion page
that appears.
c)Visit the following Microsoft Web site:
http://www.microsoft.com/ms.htm
d)Click Microsoft.com Guide in the upper-right corner of the page and
then click Contact Us . Click the link in the Product Suggestion section of
the page that appears.
e)Visit the following Microsoft Product Feedback Web site
http://register.microsoft.com/mswish/suggestion.asp
and then complete and submit the form.

2. E-mail - To send comments or suggestions via e-mail, use the following
Microsoft Wish Program e-mail address, mswish@microsoft.com.

3. FAX - To send comments or suggestions via FAX, use the following
Microsoft FAX number, (425) 936-7329.
NOTE : Address the FAX to the attention of the Microsoft Wish Program.

4. US Mail - To send comments or suggestions via US Mail, use the following
Microsoft mailing address:
Microsoft Corporation
Attn. Microsoft Wish Program
One Microsoft Way
Redmond, WA 98052-6399

Thank you once more for using Microsoft NewsGroup!

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
---------------------------------------------------------
*MORE INFORMATION
Each product suggestion is read by a member of our product feedback team,
classified for easy access, and routed to the product or service team to
drive Microsoft product and/or service improvements. Because we receive an
abundance of suggestions (over 69,000 suggestions a year!) we can't
guarantee that each request makes it into a final product or service. But
we can tell you that each suggestion has been received and is being
reviewed by the team that is most capable of addressing it.

All product or service suggestions received become the sole property of
Microsoft. Should a suggestion be implemented, Microsoft is under no
obligation to provide compensation.