Jump to content

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

39 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

Posted

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

Posted

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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

  • 2 weeks later...
Posted (edited)

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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

  • 3 weeks later...
Posted

Anyone?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

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

 

Posted

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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

  • 3 months later...
Posted

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

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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

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.

  • 1 month later...
Posted

_TS_Wrapper_TriggerDateTime should do what you are looking for.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

  • 2 months later...
Posted (edited)

Hey @water,

First time testing this UDF and I am having issues getting started. I keep getting many "'With' cannot be nested." Errors.

Simple Code:

#include <TaskScheduler.au3>

Global $oService = _TS_Open()

Errors:

Spoiler
>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\Administrator\Desktop\TaskScheduler 1.5.1.0\Uap Update Installer.au3" /UserParams    
+>09:41:03 Starting AutoIt3Wrapper (19.1127.1402.0} from:SciTE.exe (4.2.0.0)  Keyboard:00000409  OS:WIN_81/  CPU:X64 OS:X64  Environment(Language:0409)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper
>Running AU3Check (3.3.12.0)  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\Administrator\Desktop\TaskScheduler 1.5.1.0\Uap Update Installer.au3
"C:\Users\Administrator\Desktop\TaskScheduler 1.5.1.0\TaskScheduler.au3"(1173,24) : error: 'With' cannot be nested.
        With $oTaskDefinition
        ~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Administrator\Desktop\TaskScheduler 1.5.1.0\TaskScheduler.au3"(1178,23) : error: 'With' cannot be nested.
                    With $oTaskAction
                    ~~~~~~~~~~~~~~~~~^
"C:\Users\Administrator\Desktop\TaskScheduler 1.5.1.0\TaskScheduler.au3"(1195,135) : error: missing separator character before keyword.
                                __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $sQuerySection, $sQueryProperties, $iFormat, $bIgnoreNoValues, "To", .To
                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Administrator\Desktop\TaskScheduler 1.5.1.0\TaskScheduler.au3"(1222,21) : error: 'With' cannot be nested.
                With $oPrincipal
                ~~~~~~~~~~~~~~~~^
"C:\Users\Administrator\Desktop\TaskScheduler 1.5.1.0\TaskScheduler.au3"(1254,28) : error: 'With' cannot be nested.
                With $oRegistrationInfo
                ~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Administrator\Desktop\TaskScheduler 1.5.1.0\TaskScheduler.au3"(1269,24) : error: 'With' cannot be nested.
                With $oTaskSettings
                ~~~~~~~~~~~~~~~~~~~^
"C:\Users\Administrator\Desktop\TaskScheduler 1.5.1.0\TaskScheduler.au3"(1307,25) : error: 'With' cannot be nested.
                    With $oIdleSettings
                    ~~~~~~~~~~~~~~~~~~~^
"C:\Users\Administrator\Desktop\TaskScheduler 1.5.1.0\TaskScheduler.au3"(1315,32) : error: 'With' cannot be nested.
                    With $oTaskNetworkSettings
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Administrator\Desktop\TaskScheduler 1.5.1.0\TaskScheduler.au3"(1325,24) : error: 'With' cannot be nested.
                    With $oTaskTrigger
                    ~~~~~~~~~~~~~~~~~~^
"C:\Users\Administrator\Desktop\TaskScheduler 1.5.1.0\TaskScheduler.au3"(1393,28) : error: 'With' cannot be nested.
                        With $oTaskRepetition
                        ~~~~~~~~~~~~~~~~~~~~~^
C:\Users\Administrator\Desktop\TaskScheduler 1.5.1.0\Uap Update Installer.au3 - 10 error(s), 0 warning(s)
!>09:41:04 AU3Check ended. Press F4 to jump to next error.rc:2
+>09:41:04 AutoIt3Wrapper Finished.
>Exit code: 2    Time: 0.7822

 

With so many people being able to run this without issues, I am thinking it's some setting in my AutoIT I need to change?

Let me know what you think!

UDF Version: 1.5.1.0

Thanks.

Edited by Davidowicza
Posted

Seems you are running a quite old version of AutoIt:

3.3.12.0 - 1st June, 2014

Is it possible to update to the latest production release?
According to the history file a few issues with "With/EndWith" have been fixed.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

Looks like when we got our new PCs a couple months ago I focused on updating the SciTE rather than Autoit itself.... don't mind me I'll be in the corner :whistle:

Thanks, haha.

  • 2 months later...
Posted

hm...

Quote

; Modified.......: 20201123 (YYYYMMDD)

Quite interesting date ..... ;)

But seriously:
Could you add this:
 

; Forum link ....: https://www.autoitscript.com/forum/files/file/487-task-scheduler/
; Forum link ....: https://www.autoitscript.com/forum/topic/200068-creating-a-brushed-up-task-scheduler-udf/

to the header ?

When I download UDF form forum or some form github, after few years when I sombody want to check whats new then this information could be very handy, in each UDF

Oops... I should change couple of my own :)

 

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

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...