none
How to get task file path using Microsoft.Win32.TaskScheduler.dll? RRS feed

  • Question

  • Hello,

    I want to get the task file path using Microsoft.Win32.TaskScheduler.dll, but how to get the execAction.Path from task.Definition.Actions? My code is below.

    Imports Microsoft.Win32.TaskScheduler

      Dim ts As New TaskService
            Dim taskFolder As TaskFolder = ts.GetFolder("\")

           For Each task As Task In taskFolder.Tasks 

                MessageBox.Show(task.Definition.Actions(0).) 'How to get the execAction.Path?
            Next


    • Edited by gaxjyxq Saturday, August 11, 2018 12:29 PM
    • Moved by Baron Bi Monday, August 13, 2018 1:42 AM
    Saturday, August 11, 2018 12:29 PM

Answers

  • I have found the way, is it right?

      Dim ts As New TaskService
            Dim taskFolder As TaskFolder = ts.GetFolder("\")

            For Each task As Task In taskFolder.Tasks
                Dim execAction As ExecAction = CType(task.Definition.Actions(0), ExecAction)
                MessageBox.Show(execAction.Path)

            Next

    • Marked as answer by gaxjyxq Monday, August 13, 2018 5:49 AM
    Saturday, August 11, 2018 12:35 PM

All replies

  • I have found the way, is it right?

      Dim ts As New TaskService
            Dim taskFolder As TaskFolder = ts.GetFolder("\")

            For Each task As Task In taskFolder.Tasks
                Dim execAction As ExecAction = CType(task.Definition.Actions(0), ExecAction)
                MessageBox.Show(execAction.Path)

            Next

    • Marked as answer by gaxjyxq Monday, August 13, 2018 5:49 AM
    Saturday, August 11, 2018 12:35 PM
  • Hi,

    thanks for posting here.

    Since your case is more related to VB codes, I will move this case to VB forum for better support.

    Your understanding and cooperation will be grateful.

    Best Regards,

    Baron Bi


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, August 13, 2018 1:42 AM
  • Hi

    I am sorry I can't download Microsoft.Win32.TaskScheduler.dll, but I can use TaskScheduler.dll, here is my method.

    Imports TaskScheduler
    
        Public Shared Sub getpath()
            Dim ts As TaskSchedulerClass = New TaskSchedulerClass()
            ts.Connect(Nothing, Nothing, Nothing, Nothing)
            Dim folder As ITaskFolder = ts.GetFolder("\")
            Dim tasks_exists As IRegisteredTaskCollection = folder.GetTasks(1)
    
            For i As Integer = 1 To tasks_exists.Count
                Dim t As IRegisteredTask = tasks_exists(i)
                MessageBox.Show(t.Path)
            Next
        End Sub
    

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, August 13, 2018 3:02 AM