You can use ITaskScheduler to manipulatge the jobs that are created using
the scheduled tasks.
I doubt if this could be done using a vbscript, but you could use .net or
c/c++ to acheive this. Below is a sample code which uses c for the same. You
can also check the link at
http://forum.valhallalegends.com/phpbbs/index.php?PHPSESSID=8d3f544d2d54b279e8af
23af6ae98417&topic=9931.msg92723
which has a implementaion variation of the above code.
#include <windows.h>
#include <initguid.h>
#include <ole2.h>
#include <mstask.h>
#include <msterr.h>
#include <wchar.h>
#define TASKS_TO_RETRIEVE 5
int main(int argc, char **argv)
{
HRESULT hr = S_OK;
ITaskScheduler *pITS;
/////////////////////////////////////////////////////////////////
// Call CoInitialize to initialize the COM library and
// then call CoCreateInstance to get the Task Scheduler object.
/////////////////////////////////////////////////////////////////
hr = CoInitialize(NULL);
if (SUCCEEDED(hr))
{
hr = CoCreateInstance(CLSID_CTaskScheduler,
NULL,
CLSCTX_INPROC_SERVER,
IID_ITaskScheduler,
(void **) &pITS);
if (FAILED(hr))
{
CoUninitialize();
return hr;
}
}
else
{
return hr;
}
/////////////////////////////////////////////////////////////////
// Call ITaskScheduler::Enum to get an enumeration object.
/////////////////////////////////////////////////////////////////
IEnumWorkItems *pIEnum;
hr = pITS->Enum(&pIEnum);
pITS->Release();
if (FAILED(hr))
{
CoUninitialize();
return hr;
}
/////////////////////////////////////////////////////////////////
// Call IEnumWorkItems::Next to retrieve tasks. Note that
// this example tries to retrieve five tasks for each call.
/////////////////////////////////////////////////////////////////
LPWSTR *lpwszNames;
DWORD dwFetchedTasks = 0;
while (SUCCEEDED(pIEnum->Next(TASKS_TO_RETRIEVE,
&lpwszNames,
&dwFetchedTasks))
&& (dwFetchedTasks != 0))
{
///////////////////////////////////////////////////////////////
// Process each task. Note that this example prints the
// name of each task to the screen.
//////////////////////////////////////////////////////////////
while (dwFetchedTasks)
{
wprintf(L"%s\n", lpwszNames[--dwFetchedTasks]);
CoTaskMemFree(lpwszNames[dwFetchedTasks]);
}
CoTaskMemFree(lpwszNames);
}
pIEnum->Release();
CoUninitialize();
return S_OK;
}
>I need to write a script that queries 4 servers regarding the status of
> schedueled jobs in win 2000 and win2k3 and display the status in an asp
[quoted text clipped - 6 lines]
>
> Thanks for your help
SalamElias - 26 Jul 2006 20:55 GMT
"Thanks, I searched the web site and wasn't able to find other versions (vb
or C#). have you the url for those varitions.
While I was looking for this info, I ran across the schtasks shipped with
win2k3.
It is interesting but when I run it from DOS "schtasks /query" I get 3
fields, taskname", "Next run time" and "status". All fields are populated
except the status one,it is empty.
Any idea
> You can use ITaskScheduler to manipulatge the jobs that are created using
> the scheduled tasks.
[quoted text clipped - 91 lines]
> >
> > Thanks for your help
Luke Zhang [MSFT] - 27 Jul 2006 03:30 GMT
Hello,
You may take a look at this Task Scheduler Library:
http://www.codeproject.com/csharp/tsnewlib.asp
It provide a Library project which can be used in VB.NET and C#.
Sincerely,
Luke Zhang
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Hitesh Ramchandani - 27 Jul 2006 05:29 GMT
The status is displayed only if the job had previously errored out or if the
task is currently running.
Bascially, if you do not see a status while looking at the scheduled task in
explorer, then most likely you would not see one from the schtasks as well.
-Hitesh
> "Thanks, I searched the web site and wasn't able to find other versions
> (vb
[quoted text clipped - 105 lines]
>> >
>> > Thanks for your help