dahall / TaskScheduler

Provides a .NET wrapper for the Windows Task Scheduler. It aggregates the multiple versions, provides an editor and allows for localization.
MIT License
1.23k stars 192 forks source link

Getting COMExcpetion when attempting to register changes in a Windows 8.1 PC #136

Closed dahall closed 6 years ago

dahall commented 6 years ago

I've create a task using this library, that worked.

Now when I use the TaskEdit dialog in the following way:

Using D As New TaskEditDialog()
    Using Tsk As Task = ts.GetTask("\MyTasks\Task1")
        D.Editable = True
        D.RegisterTaskOnAccept = True
        D.Initialize(Tsk)
    End Using
End Using

I get a COMException with error code -2147216615 and a message of (45,8):Period:. I have noticed that if I change the Configure For dropdown to Windows 7, Windows Server 2008 R2 it saves.

What am I doing wrong or does this library not support Windows 8.1 as yet?

The output from D.Task.xml is:

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
    <RegistrationInfo>
        <Source>MyApp</Source>
        <Author>Me</Author>
        <Description>Collect Totals</Description>
    </RegistrationInfo>
    <Triggers>
        <CalendarTrigger>
            <StartBoundary>2013-11-12T18:00:00</StartBoundary>
            <Enabled>true</Enabled>
            <ScheduleByDay>
                <DaysInterval>1</DaysInterval>
            </ScheduleByDay>
        </CalendarTrigger>
    </Triggers>
    <Settings>
        <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
        <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
        <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
        <AllowHardTerminate>true</AllowHardTerminate>
        <StartWhenAvailable>true</StartWhenAvailable>
        <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
        <IdleSettings>
            <Duration>PT10M</Duration>
            <WaitTimeout>PT1H</WaitTimeout>
            <StopOnIdleEnd>true</StopOnIdleEnd>
            <RestartOnIdle>false</RestartOnIdle>
        </IdleSettings>
        <AllowStartOnDemand>true</AllowStartOnDemand>
        <Enabled>true</Enabled>
        <Hidden>true</Hidden>
        <RunOnlyIfIdle>false</RunOnlyIfIdle>
        <WakeToRun>true</WakeToRun>
        <ExecutionTimeLimit>PT72H</ExecutionTimeLimit>
        <Priority>7</Priority>
        <RestartOnFailure>
            <Interval>PT1M</Interval>
            <Count>3</Count>
        </RestartOnFailure>
    </Settings>
    <Actions Context="Author">
        <Exec>
            <Command>C:\Users\darm\Documents\Visual Studio 2010\Projects\MyApp\Deliverable\Application\Task Runner.exe</Command>
            <Arguments>action=1</Arguments>
        </Exec>
    </Actions>
    <Principals>
        <Principal id="Author">
            <UserId>DG750\darm</UserId>
            <LogonType>InteractiveToken</LogonType>
            <RunLevel>LeastPrivilege</RunLevel>
        </Principal>
    </Principals>
</Task>

Originally posted: 2014-01-07T09:53:41

dahall commented 6 years ago

I've just downloaded the latest version 2.0.3 and it still does not work. The exception is shown below:

System.Runtime.InteropServices.COMException (0x80041319): (45,8):Period:
   at Microsoft.Win32.TaskScheduler.V2Interop.ITaskFolder.RegisterTaskDefinition(String Path, ITaskDefinition pDefinition, Int32 flags, Object UserId, Object password, TaskLogonType LogonType, Object sddl)
   at Microsoft.Win32.TaskScheduler.TaskFolder.RegisterTaskDefinition(String Path, TaskDefinition definition, TaskCreation createType, String UserId, String password, TaskLogonType LogonType, String sddl)
   at Microsoft.Win32.TaskScheduler.TaskFolder.RegisterTaskDefinition(String Path, TaskDefinition definition)
   at Microsoft.Win32.TaskScheduler.Task.RegisterChanges()
   at Microsoft.Win32.TaskScheduler.TaskEditDialog.okBtn_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

************** Loaded Assemblies **************
mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.7905 (win9rel.050727-7900)
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/mscorlib.dll
----------------------------------------
Scheduled Task Manager
    Assembly Version: 3.0.0.3
    Win32 Version: 3.0.0.3
    CodeBase: file:///C:/Users/darm/Documents/Visual%20Studio%202010/Projects/MXBusiness/Deliverable/Application/Scheduled%20Task%20Manager.exe
----------------------------------------
Database
    Assembly Version: 3.0.0.6
    Win32 Version: 3.0.0.6
    CodeBase: file:///C:/Users/darm/Documents/Visual%20Studio%202010/Projects/MXBusiness/Deliverable/Application/Database.DLL
----------------------------------------
log4net
    Assembly Version: 1.2.10.0
    Win32 Version: 1.2.10.0
    CodeBase: file:///C:/Users/darm/Documents/Visual%20Studio%202010/Projects/MXBusiness/Deliverable/Application/log4net.DLL
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.7905 (win9rel.050727-7900)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.7905 (win9rel.050727-7900)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.7905 (win9rel.050727-7900)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
Microsoft.VisualBasic
    Assembly Version: 8.0.0.0
    Win32 Version: 8.0.50727.7905 (win9rel.050727-7900)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
TranslationManager
    Assembly Version: 3.0.0.3
    Win32 Version: 3.0.0.3
    CodeBase: file:///C:/Users/darm/Documents/Visual%20Studio%202010/Projects/MXBusiness/Deliverable/Application/TranslationManager.DLL
----------------------------------------
System.Configuration
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.7905 (win9rel.050727-7900)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.7905 (win9rel.050727-7900)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Xml.Linq
    Assembly Version: 3.5.0.0
    Win32 Version: 3.5.30729.7903 built by: Win9Rel
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml.Linq/3.5.0.0__b77a5c561934e089/System.Xml.Linq.dll
----------------------------------------
System.Core
    Assembly Version: 3.5.0.0
    Win32 Version: 3.5.30729.7903 built by: Win9Rel
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Core/3.5.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System.Data.Entity
    Assembly Version: 3.5.0.0
    Win32 Version: 3.5.30729.7903 built by: Win9Rel
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Data.Entity/3.5.0.0__b77a5c561934e089/System.Data.Entity.dll
----------------------------------------
System.Data
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.7905 (win9rel.050727-7900)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_64/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Web
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.7905 (win9rel.050727-7900)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_64/System.Web/2.0.0.0__b03f5f7f11d50a3a/System.Web.dll
----------------------------------------
System.Transactions
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.7905 (win9rel.050727-7900)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_64/System.Transactions/2.0.0.0__b77a5c561934e089/System.Transactions.dll
----------------------------------------
System.EnterpriseServices
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.7905 (win9rel.050727-7900)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_64/System.EnterpriseServices/2.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
----------------------------------------
System.Runtime.Serialization
    Assembly Version: 3.0.0.0
    Win32 Version: 3.0.4506.7903 (Win9Rel.030729-7900)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Runtime.Serialization/3.0.0.0__b77a5c561934e089/System.Runtime.Serialization.dll
----------------------------------------
DevExpress.XtraEditors.v12.2
    Assembly Version: 12.2.13.0
    Win32 Version: 12.2.13.0
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/DevExpress.XtraEditors.v12.2/12.2.13.0__b88d1754d700e49a/DevExpress.XtraEditors.v12.2.dll
----------------------------------------
DevExpress.Utils.v12.2
    Assembly Version: 12.2.13.0
    Win32 Version: 12.2.13.0
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/DevExpress.Utils.v12.2/12.2.13.0__b88d1754d700e49a/DevExpress.Utils.v12.2.dll
----------------------------------------
DevExpress.Data.v12.2
    Assembly Version: 12.2.13.0
    Win32 Version: 12.2.13.0
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/DevExpress.Data.v12.2/12.2.13.0__b88d1754d700e49a/DevExpress.Data.v12.2.dll
----------------------------------------
Anonymously Hosted DynamicMethods Assembly
    Assembly Version: 0.0.0.0
    Win32 Version: 2.0.50727.7905 (win9rel.050727-7900)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_64/mscorlib/2.0.0.0__b77a5c561934e089/mscorlib.dll
----------------------------------------
Microsoft.Win32.TaskScheduler
    Assembly Version: 2.0.0.27238
    Win32 Version: 2.0.0.0
    CodeBase: file:///C:/Users/darm/Documents/Visual%20Studio%202010/Projects/MXBusiness/Deliverable/Application/Microsoft.Win32.TaskScheduler.DLL
----------------------------------------
Microsoft.Win32.TaskSchedulerEditor
    Assembly Version: 2.0.0.27241
    Win32 Version: 2.0.0.0
    CodeBase: file:///C:/Users/darm/Documents/Visual%20Studio%202010/Projects/MXBusiness/Deliverable/Application/Microsoft.Win32.TaskSchedulerEditor.DLL
----------------------------------------
TimeSpan2
    Assembly Version: 2.0.2.14660
    Win32 Version: 2.0.2.0
    CodeBase: file:///C:/Users/darm/Documents/Visual%20Studio%202010/Projects/MXBusiness/Deliverable/Application/TimeSpan2.DLL
----------------------------------------
GroupControls
    Assembly Version: 1.3.8.27120
    Win32 Version: 1.3.8.0
    CodeBase: file:///C:/Users/darm/Documents/Visual%20Studio%202010/Projects/MXBusiness/Deliverable/Application/GroupControls.DLL
----------------------------------------
Accessibility
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.7905 (win9rel.050727-7900)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Accessibility/2.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
----------------------------------------
CustomMarshalers
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.7905 (win9rel.050727-7900)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_64/CustomMarshalers/2.0.0.0__b03f5f7f11d50a3a/CustomMarshalers.dll
----------------------------------------
Microsoft.mshtml
    Assembly Version: 7.0.3300.0
    Win32 Version: 7.0.3300.0
    CodeBase: file:///C:/WINDOWS/assembly/GAC/Microsoft.mshtml/7.0.3300.0__b03f5f7f11d50a3a/Microsoft.mshtml.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

Originally posted: 2014-01-16T12:50:41

dahall commented 6 years ago

Fixed in 2.0.1 release

** Closed by dahall 1/7/2014 1:17 PM

Originally posted: 2014-01-16T16:39:03

dahall commented 6 years ago

I just attached a zip file. Please unzip all of it and then run TestTaskService.exe. Choose "Editor test" and change some of the values for the task that pops up, click Ok, and then see if there is an error. Test changing values and even the "Configure for:" dropdown. Let me know what you find. By the way, your error log shows that you have the 2.0.0 binaries and not the 2.0.3.

Originally posted: 2014-01-16T16:43:47

dahall commented 6 years ago

I did a bunch of work in this area for the 2.1.1 release. Will you check and let me know if the error still appears?

Originally posted: 2014-04-17T17:27:21

dahall commented 6 years ago

Originally posted: 2014-09-04T14:54:33