![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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 |
#3
| |||
| |||
|
|
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 |
#4
| |||
| |||
|
#5
| |||
| |||
|
|
"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 |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |