HighTechTalks DotNet Forums  

schedueled jobs

Dotnet Scripting microsoft.public.dotnet.scripting


Discuss schedueled jobs in the Dotnet Scripting forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
SalamElias
 
Posts: n/a

Default schedueled jobs - 07-26-2006 , 09:40 AM






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 page

Is there a WMI or any other object class that can return schedueled jobs
infos in vb script not created using either a script or AT.exe.
On MSDN, I ubnderstood Win32_ScheduledJob cannot return information about
jobs that are either created by or modified by the Scheduled Task wizard.

Thanks for your help


Reply With Quote
  #2  
Old   
Hitesh Ramchandani
 
Posts: n/a

Default Re: schedueled jobs - 07-26-2006 , 01:27 PM






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/php...=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;
}
"SalamElias" <eliassal (AT) online (DOT) nospam> wrote

Quote:
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
page

Is there a WMI or any other object class that can return schedueled jobs
infos in vb script not created using either a script or AT.exe.
On MSDN, I ubnderstood Win32_ScheduledJob cannot return information about
jobs that are either created by or modified by the Scheduled Task wizard.

Thanks for your help




Reply With Quote
  #3  
Old   
SalamElias
 
Posts: n/a

Default Re: schedueled jobs - 07-26-2006 , 03:55 PM



"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


"Hitesh Ramchandani" wrote:

Quote:
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/php...=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;
}
"SalamElias" <eliassal (AT) online (DOT) nospam> wrote in message
news:89E7A2DC-580D-43D2-BBB7-584F4D644265 (AT) microsoft (DOT) com...
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
page

Is there a WMI or any other object class that can return schedueled jobs
infos in vb script not created using either a script or AT.exe.
On MSDN, I ubnderstood Win32_ScheduledJob cannot return information about
jobs that are either created by or modified by the Scheduled Task wizard.

Thanks for your help





Reply With Quote
  #4  
Old   
AT
 
Posts: n/a

Default Re: schedueled jobs - 07-26-2006 , 10:30 PM



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/subscripti...ult.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/subscripti...t/default.aspx.
==================================================

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




Reply With Quote
  #5  
Old   
Hitesh Ramchandani
 
Posts: n/a

Default Re: schedueled jobs - 07-27-2006 , 12:29 AM



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

"SalamElias" <eliassal (AT) online (DOT) nospam> wrote

Quote:
"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


"Hitesh Ramchandani" wrote:

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/php...=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;
}
"SalamElias" <eliassal (AT) online (DOT) nospam> wrote in message
news:89E7A2DC-580D-43D2-BBB7-584F4D644265 (AT) microsoft (DOT) com...
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
page

Is there a WMI or any other object class that can return schedueled
jobs
infos in vb script not created using either a script or AT.exe.
On MSDN, I ubnderstood Win32_ScheduledJob cannot return information
about
jobs that are either created by or modified by the Scheduled Task
wizard.

Thanks for your help







Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.