Jump to content
water

Creating a "brushed up" Task Scheduler UDF?

Would you like to see a brushed up Task Scheduler UDF (inlcuding help files, examples ...)?  

29 members have voted

  1. 1. Would you like to see such a brushed up UDF?

    • Yes
    • Don't mind
    • Maybe later
      0
    • No
      0


Recommended Posts

Thanks water.  My theory why it works this way is the task definition object is not assigned to a task until it is registered.  So when you use the task object to get the task definition object, it is the definition of when it was last registered.  If you changed the task definition object, but not register it again, it just changes it for that particular task definition object.  You could get the definition again to a different task definition object, and make different changes to it.  You would then have two definitions for the same task, but only the one registered would keep the changes.  That is how I see it anyway.  Why it was done this way?  Only MS knows.    

 

Adam

Share this post


Link to post
Share on other sites

All object models of Microsoft products I have worked with have a "hierarchy" of objects.
An Excel Workbook is the parent of a Worksheet is the parent of a Range ... Means: You have to define a Workbook before you can define a Worksheet before you can define a Range ... That's why this objects can provide a "parent" property.

The Task Scheduler object model does not provide "parent" properties, just methods and further properties. So I think the map of the object model I have drawn in the wiki might not be fully correct. That would explain why it doesn't behave as expected. As Microsofts documentation and sources on the web do not explain it in depth I think we will have to live with what we have :)

WIll release an updated version quite soon :)
 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-07-21 - Version 1.5.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-27 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

Version 1.5.1.0 released

Changelog can be found on the download page and the history in the ZIP file.

For download please see my signature below.

Please play with this version and tell me what doesn't work or is missing!


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-07-21 - Version 1.5.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-27 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

With version 1.4.0.0 function _TS_TaskValidate to check the task Definition for errors before Registration has been added.
A few checks have already been implemented but I'm sure there are more sensible checks to be done.

Which problems did you find when working with the UDF?
Could this problems be found by _TS_TaskValidate?

Please let me know so I can add them to the function!

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-07-21 - Version 1.5.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-27 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

Anyone?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-07-21 - Version 1.5.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-27 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

Hi water,

I got caught up on some year end server migration projects, and then winter break.  I did some testing of _TS_TaskValidate, but not a whole lot.  I didn't find any issues with the tests I have done.   I plan on testing some more, after server migrations are completed.  

 

Adam

 

Share this post


Link to post
Share on other sites

Hi Adam,

I hope you had a great Xmas vacation and a good start into 2020!

The _TS_TaskValidate function is just a sceleton for more tests to be done to make sure _TS_TaskRegister runs without errors.
Currently all problems I did find on the forum get checked. But I'm sure there are more ... :)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-07-21 - Version 1.5.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-27 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

The example scripts that come with the UDF have full blown error checking included.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-07-21 - Version 1.5.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-27 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

Hi Water, I'm using this to create a scheduled task from a previously exported XML and was working great using a test script, but when trying to implement into my main script it is failing every time with a COM error.

Turns out, it was because I am using a custom error handler for my DB connections which is interfering with the _TS_Open() > _TS_ErrorNotify(4)

Global $iEventError = 0             ;Checks for COM errors
Global $oMyError = ObjEvent("AutoIt.Error", "ErrFunc") ;Install a custom error handler for any DB connection issues


Global $oService = _TS_Open()
If @error <> 0 Then Exit MsgBox($MB_ICONERROR, "Task Scheduler UDF", "Error connecting to the Task Scheduler Service. @error = " & @error & ", @extended = " & @extended & @CRLF & @CRLF & _TS_ErrorText(@error))


Func ErrFunc()
    ConsoleWrite("We intercepted a COM Error !" & @CRLF & _
                "Number: 0x" & Hex($oMyError.number, 8) & @CRLF & @TAB & _
                "Description: " & $oMyError.windescription & @CRLF & @TAB & _
                "At line: " & $oMyError.scriptline & @CRLF)
    $iEventError = 1                                                                                ; Use to check when a COM Error occurs
EndFunc   ;==>ErrFunc

Returns:  Error connecting to the Task Scheduler Service.  error = 101, extended = 203, _TS_Open(101):  Error reating the COM error handler.  extended is set to the error code returned by _TS_ErrorNotify

 

Is there a way to modify the TaskScheduler.au3 to use my custom error handler?

Thanks,

Mike


hmm... I guess I have to have a signature...

Share this post


Link to post
Share on other sites
Posted (edited)

You could call _TS_ErrorNotify(2) before calling _TS_Open to get detailed error information.

Or you create your custom COM error handler after _TS_Open.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-07-21 - Version 1.5.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-27 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

Well, this is getting complicated as I need #RequireAdmin for this, but as I'm building this into an installer.  if I copy my files over while under #RequireAdmin it then prompts for Admin UAC every time I run the files that were copied over that way.

 

Ugh.  I think I'm going to split this Task Create part into a separate .a3x file and run using a ShellExecute after I create the .xml from the initial setup script.  That way I don't need to worry about the COM error handler.


hmm... I guess I have to have a signature...

Share this post


Link to post
Share on other sites

_TS_Wrapper_TriggerDateTime should do what you are looking for.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-07-21 - Version 1.5.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-27 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

Does The UDF support run a task and repeating at a 15 minute interval , I looked at _TS_Wrapper_TriggerDateTime and could not see any way to do it

Share this post


Link to post
Share on other sites

I have manually created a task with your specifications and get the following XML (part of the full task definition) for the trigger:

Quote

  <Triggers>
    <TimeTrigger>
      <Repetition>
        <Interval>PT15M</Interval>
        <Duration>P1D</Duration>
        <StopAtDurationEnd>false</StopAtDurationEnd>
      </Repetition>
      <StartBoundary>2020-06-06T13:00:00</StartBoundary>
      <Enabled>true</Enabled>
    </TimeTrigger>
  </Triggers>

You could now use one of the ways described in the wiki to create a task with the UDF.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-07-21 - Version 1.5.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-27 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...