[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

vb.net scheduled task window

Posted on 2014-12-23
3
Medium Priority
?
98 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
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…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

650 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