Quantcast
Channel: Task Scheduler Managed Wrapper
Viewing all articles
Browse latest Browse all 2206

New Post: Two Bugs...

$
0
0
And another bug...
The exception occurred 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) in C:\Users\dahall\Documents\Visual Studio 2010\Projects\TaskService\TaskFolder.cs:line 430
at Microsoft.Win32.TaskScheduler.TaskFolder.RegisterTaskDefinition(String Path, TaskDefinition definition) in C:\Users\dahall\Documents\Visual Studio 2010\Projects\TaskService\TaskFolder.cs:line 373
And here's my code...
Dim taskService As New TaskService()
Dim newTask As TaskDefinition = taskService.NewTask
Dim logonTriggerDefinition As LogonTrigger = New LogonTrigger()

If delayed = True Then
  logonTriggerDefinition.Delay = New TimeSpan(0, 0, delayTimeInMinutes, 0, 0)
End If

Dim exePathInfo As New IO.FileInfo(Application.ExecutablePath)
newTask.Actions.Add(New ExecAction(exePathInfo.FullName, "-myargument", exePathInfo.DirectoryName))
exePathInfo = Nothing

newTask.Triggers.Add(logonTriggerDefinition)
newTask.Principal.RunLevel = TaskRunLevel.Highest
newTask.RegistrationInfo.Description = "My Task"
newTask.Principal.LogonType = TaskLogonType.InteractiveToken

With newTask.Settings
  .Compatibility = TaskCompatibility.V2
  .AllowDemandStart = True
  .DisallowStartIfOnBatteries = False
  .RunOnlyIfIdle = False
  .StopIfGoingOnBatteries = False
  .AllowHardTerminate = False
  .ExecutionTimeLimit = Nothing
End With

taskService.RootFolder.RegisterTaskDefinition("My Task", newTask)

newTask.Dispose()
taskService.Dispose()

newTask = Nothing
taskService = Nothing

Viewing all articles
Browse latest Browse all 2206

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>