Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 808
  • Last Modified:

Task Scheduler

Using Windows 98 (or 95) -

When a MS Windows software package (such as the SDK) is being installed - the Task Scheduler is "paused". When the installation is complete it is "unpaused".

The task scheduler icon resides in the system tray - right clicking on it gives two choice "Open" or "pause ..."

I have been searching MSDN for sometime and have come up with nothing on the subject - therefore I have come to the conclusion that the functions are undocumented.

Does anyone know how to pause and unpause the Task Scheduler ??

DarrinE
0
DarrinE
Asked:
DarrinE
  • 7
  • 3
  • 3
  • +2
1 Solution
 
chensuCommented:
It is documented. See

Task Scheduler
http://msdn.microsoft.com/isapi/msdnlib.idc?theURL=/library/psdk/taskschd/ts_portal_690l.htm

TaskSched: Task Scheduler Sample
http://msdn.microsoft.com/isapi/msdnlib.idc?theURL=/library/devprods/vs6/visualc/vcsample/vcsmptasksched.htm

It is a service on Windows NT. So, you can pause and resume the service just like other services.

C/C++ Code Example: Starting Task Scheduler
http://msdn.microsoft.com/isapi/msdnlib.idc?theURL=/library/psdk/taskschd/ts_using_2182.htm
0
 
DarrinEAuthor Commented:
Chensu - I knew of the pages identified by you - I have read and reread them several times - what I am trying to do is "pause" the scheduler while my program runs

I am not trying to "play" with any of the tasks (or pause a specific task) - I am trying to pause the service so it does not run at all and can be unpaused when my program is ready for it to go

0
 
NickRepinCommented:
It seems it is undocumented.
I can find the info you want for 600 points+grade A.
0
Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

 
DarrinEAuthor Commented:
OK - 400 and a grade "A" - working example in C - sounds better - I'll have no points left but at least I'll have an answer <s>

DarrinE
0
 
byangCommented:
Can I bid 399 points and a grade A for working code ?
0
 
byangCommented:
And it's simple, nothing complicated.
0
 
NickRepinCommented:
Sure, no problem.
0
 
DarrinEAuthor Commented:
OK - well how about this - first one in with the first working example gets the points -  now remember I work on win98/win95 and I work on in C - 400 points is what is available at the moment (sorry guys I dont have any more at the moment - it would also be nice if the sample works on NT but not absolute)

DarrinE
0
 
robpittCommented:
Sorry for piping some of you folks at the post but I've done this one and could also do with the points.
This topici is looosly documented in MSDN, search for things like "SAGE" and "Task Scheduler".

Anyway heres some working code source code...

Enjoy...

-ROB


//TaskSchd.H
#define TASKSCHEDULER_GETSTATE     (0)
#define TASKSCHEDULER_ENABLE       (1)
#define TASKSCHEDULER_DISABLE      (2)

int WINAPI TaskSchedulerEnable(int newState);
//Call with one of the 3 settings above dependant upon
//whether you want to query the current state or change
//it to a new state. It returns the old state or 0 on error.





//TaskSchd.C
#include <windows.h>
#include "taskschd.h"

#define WM_TASKSCHEDULER_ENABLE     (WM_USER+6)
#define WM_TASKSCHEDULER_DISABLE    (WM_USER+7)
#define WM_TASKSCHEDULER_GETSTATUS  (WM_USER+8)

#define TASKSCHEDULER_WINDOWCLASS   ("SAGEWINDOWCLASS")
#define TASKSCHEDULER_WINDOW        ("SYSTEM AGENT COM WINDOW")

int WINAPI TaskSchedulerEnable(int newState)
{
    HWND hWnd;
    int state;
   
    hWnd=FindWindow(TASKSCHEDULER_WINDOWCLASS,TASKSCHEDULER_WINDOW);
    if (!hWnd) return 0;

    state=SendMessage(hWnd,WM_TASKSCHEDULER_GETSTATUS,0,0);
    if (state==TASKSCHEDULER_ENABLE)
    {
        if (newState==TASKSCHEDULER_DISABLE) SendMessage(hWnd,WM_TASKSCHEDULER_DISABLE,0,0);
        return state;
    }
    else if (state==TASKSCHEDULER_DISABLE)
    {
        if (newState==TASKSCHEDULER_ENABLE) SendMessage(hWnd,WM_TASKSCHEDULER_ENABLE,0,0);
        return state;
    }

    return 0;
}

0
 
robpittCommented:
Oh and for NT you could modify my wrapper to detect OS then call either the Win95 version (as above) or on NT do...
OpenService(hSC,"Schedule"), QueryServiceStatus() and  ControlService()

-ROB
0
 
byangCommented:
robpitt is correct.
0
 
DarrinEAuthor Commented:
Adjusted points from 200 to 400
0
 
DarrinEAuthor Commented:
can you give me an example for use on NT ?
0
 
DarrinEAuthor Commented:
And a direction to where some documentation might be ?? - in the interim I'll try the answer (code) you've provided

DarrinE
0
 
robpittCommented:
Search MSDN for ... "sage.dll" task scheduler ... that will find an article entitled "Guidelines for Independent Software Vendors" which covers some of old Win9X stuff.

On NT the Task Scheduler (if loaded/installed) is just another service and so you pause/resume it via the service control functions (see MSDN). Below is *pseudo-code* showing how you could make my code handle NT as well...

-ROB

if (GetVersion()&0x80000000)//detect Win9X versus WinNT
{//Win9X
    ... code from previous post
}
else
{//WinNT
    hServControl = OpenSCManager(NULL,NULL,SC_MANAGER_CONNECT);
    hSchedule = OpenService(hServControl, "Schedule", SERVICE_QUERY_STATUS|SERVICE_PAUSE_CONTINUE);
    if (!hSchedule) return 0;// Schedule not running

    QueryServiceStatus(hSchedule, &serviceStatus);
    if (serviceStatus.dwCurrentState==SERVICE_PAUSED)
    {
      if (want_to_enable) ControlService(hSchedule, SERVICE_CONTROL_CONTINUE);
        return WAS PAUSED;
    }
    else if (serviceStatus.dwCurrentState==SERVICE_RUNNING)
    {
      if (want_to_disable) ControlService(hSchedule, SERVICE_CONTROL_PAUSE);
        return WAS ENABLED;
    }
    else
        return 0 - unknown state
}
0
 
DarrinEAuthor Commented:
Many thanks for the assistance - the points are yours - what for my queries I have another one coming up along these same lines
0
 
chensuCommented:
>can you give me an example for use on NT ?

Did you have a look at the example I gave you with my very first comment?

"It is a service on Windows NT. So, you can pause and resume the service just like other services.

C/C++ Code Example: Starting Task Scheduler
http://msdn.microsoft.com/isapi/msdnlib.idc?theURL=/library/psdk/taskschd/ts_using_2182.htm"
0

Featured Post

Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

  • 7
  • 3
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now