Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Task Scheduler

Posted on 2000-04-15
17
Medium Priority
?
801 Views
Last Modified: 2013-12-03
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
Comment
Question by:DarrinE
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 3
  • 3
  • +2
17 Comments
 
LVL 23

Expert Comment

by:chensu
ID: 2720003
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
 
LVL 2

Author Comment

by:DarrinE
ID: 2720225
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
 
LVL 15

Expert Comment

by:NickRepin
ID: 2722479
It seems it is undocumented.
I can find the info you want for 600 points+grade A.
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
LVL 2

Author Comment

by:DarrinE
ID: 2724305
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
 
LVL 3

Expert Comment

by:byang
ID: 2733199
Can I bid 399 points and a grade A for working code ?
0
 
LVL 3

Expert Comment

by:byang
ID: 2733212
And it's simple, nothing complicated.
0
 
LVL 15

Expert Comment

by:NickRepin
ID: 2733448
Sure, no problem.
0
 
LVL 2

Author Comment

by:DarrinE
ID: 2733812
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
 
LVL 5

Accepted Solution

by:
robpitt earned 1600 total points
ID: 2734692
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
 
LVL 5

Expert Comment

by:robpitt
ID: 2734715
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
 
LVL 3

Expert Comment

by:byang
ID: 2735982
robpitt is correct.
0
 
LVL 2

Author Comment

by:DarrinE
ID: 2736552
Adjusted points from 200 to 400
0
 
LVL 2

Author Comment

by:DarrinE
ID: 2736553
can you give me an example for use on NT ?
0
 
LVL 2

Author Comment

by:DarrinE
ID: 2736559
And a direction to where some documentation might be ?? - in the interim I'll try the answer (code) you've provided

DarrinE
0
 
LVL 5

Expert Comment

by:robpitt
ID: 2737348
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
 
LVL 2

Author Comment

by:DarrinE
ID: 2737350
Many thanks for the assistance - the points are yours - what for my queries I have another one coming up along these same lines
0
 
LVL 23

Expert Comment

by:chensu
ID: 2738137
>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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question