Solved

vb.net scheduled task window

Posted on 2014-12-23
3
69 Views
Last Modified: 2016-06-23
Hi guys, I'm working with the below code to create a scheduled task and then bring up the properties window of that task. It has no trouble creating the task and loading the properties window, however any changes I make within that properties window is ignored. The code doesn't set a trigger for the task to run, so I click the triggers tab and set a date and time for it to begin, I then OK the window. If I then open up task scheduler and double click on my new task, the triggers tab is empty.  Even if I enter in a description, it doesn't keep it.

Not sure what I'm doing wrong?

Using ts As TaskService = New TaskService
            ' Create a new task definition and assign properties
            Dim td As TaskDefinition = ts.NewTask
            td.RegistrationInfo.Description = "Does something"

            ' Add an action (shorthand) that runs Notepad
            td.Actions.Add(New ExecAction("notepad.exe", "c:\test.log"))

            ' Register the task in the root folder
            ts.RootFolder.RegisterTaskDefinition("Test", td)

            Dim TaskName As String = "Test"

            Dim EditorForm As New TaskEditDialog()
            Dim t As Task
            t = ts.GetTask(TaskName)

            EditorForm.Editable = True
            EditorForm.Initialize(t)
             If EditorForm.ShowDialog = Windows.Forms.DialogResult.Cancel Then
                ts.RootFolder.DeleteTask(TaskName)
            End If
        End Using

Open in new window

0
Comment
Question by:amaru96
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 40514719
have a look at http://emoreau.com/Entries/Articles/2004/08/Interfacing-the-Windows-Task-Scheduler.aspx and more precisely in the comments below the article. There are a few links to free libraries.
0
 
LVL 1

Accepted Solution

by:
amaru96 earned 0 total points
ID: 40515656
Worked it out by adding the below.

 If EditorForm.ShowDialog = Windows.Forms.DialogResult.OK Then
                    ts.RootFolder.RegisterTaskDefinition(TaskName, EditorForm.TaskDefinition)
                Else
                    ts.RootFolder.DeleteTask(TaskName)
                End If

Open in new window

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
What is newest platform to convert a massive Windows Forms program to? 7 52
C# XML Get Values 4 35
Need help with a query 3 39
visual studio vb.net windows onkeyup 2 30
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question