dcsimg
Results 1 to 3 of 3

Thread: [VB6] Create, delete or enum tasks in Task Scheduler

  1. #1

    Thread Starter
    Member Dragokas's Avatar
    Join Date
    Aug 2015
    Location
    Ukraine
    Posts
    555

    [VB6] Create, delete or enum tasks in Task Scheduler

    Hi,

    this code written on Windows Interfaces (ITaskService) and primarily intended to show how to use them in above job

    IAction
    IActionCollection
    IComHandlerAction
    IEmailAction
    IExecAction
    ILogonTrigger
    IPrincipal
    IRegisteredTask
    IRegistrationInfo
    IRegistrationTrigger
    IShowMessageAction
    ITaskDefinition
    ITaskFolder
    ITaskSettings
    ITrigger
    ITriggerCollection
    I also has no source code for TLB, because I took one from Microsoft:
    Code:
    Reference=*\G{E34CB9F1-C7F7-424C-BE29-027DCC09363A}#1.0#0#C:\Windows\SysWOW64\taskschd.dll#TaskScheduler
    It's included into resources of dll. If you need one, you can wait for realization in oleexp from fafalone or just ref. your code to taskschd.dll system dll that always exist there by default.

    What code can do:
    - Create task
    - Delete task
    - Enumerate all tasks

    Support: Windows Vista+

    Note:
    For XP, see: how to use ITask (Task scheduler interfaces v.1.0).
    v 2.0 - introduced in Vista
    And extended version of 2.0 with postfixes 3 (AFAIK) is introduced in Win 8.

    Dependency: Task Scheduler ("Schedule") service should by run.

    ---
    P.S. In my sample code presented not all possible options / properties that is available, just a basic example.
    You can read everything else on MSDN, or press dot (.) near inerface variable (or F2) and see what else is present.

    Separately, I need to point that:
    - IComHandlerAction
    - IExecAction
    - IEmailAction
    - IShowMessageAction
    is derived from IAction interface, like in such way (pseudocode):
    Code:
    set IAction = ... 
    set IExecAction = IAction
    The same for: ITrigger. See example in my code. See full explanation and list of derived interfaces on MSDN.

    PPS. As about enum/killer part of code - sorry for a bit dirty code, it wasn't originally inteded to show (more for debugging). And don't bug me about it because I switched to manual parsing (that functionality is always very buggy if xml is some kind damaged, no matter what you can do, here you can't save the world using interfaces only).

    Good luck,
    Stanislav.
    Attached Files Attached Files

  2. #2
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    2,060

    Re: [VB6] Create, delete or enum tasks in Task Scheduler

    Nice project. Just wanted to note in this thread too, the taskschd.dll typelib does have a few functions here and there that will error in VB because they're typed as unsigned long (VB flat out says '<unsupported variable type>' in object browser), so if you wind up needing to use one of those or just want one less reference, then you will want to grab the latest oleexp, just released 4.5 with all the Task Scheduler 2/3 interfaces added. Apart from those (and one other array pointer issue, but in a hidden/restricted method), the interfaces are unchanged from the dll, so should work with this project as-is with just a reference switch.

  3. #3

    Thread Starter
    Member Dragokas's Avatar
    Join Date
    Aug 2015
    Location
    Ukraine
    Posts
    555

    Re: [VB6] Create, delete or enum tasks in Task Scheduler

    Hi, fafalone, thank you for adding them and revision.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width