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

New Post: Change Task Name

$
0
0
So I worked on the code a bit and so far the best way I came up with was this:
    Public Sub newTask()

        ' Create a new task definition and assign properties
        Dim td As TaskDefinition = _tskSrvc.NewTask
        td.RegistrationInfo.Description = ""

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

        ' Register the task in the root folder
        _rootFolder.RegisterTaskDefinition("THISISNTANEWTASK", td)

        Dim dlg As New TaskEditDialog(_rootFolder.Tasks("THISISNTANEWTASK"), True, True)
        _rootFolder.DeleteTask("THISISNTANEWTASK")
        dlg.TaskName = InputBox("Please enter name of Task")

        If dlg.ShowDialog() = vbOK Then

            _rootFolder.RegisterTaskDefinition(dlg.TaskName, dlg.TaskDefinition)

        End If

    End Sub
Hope this helps somebody else.

Viewing all articles
Browse latest Browse all 2206

Trending Articles



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