2017-04-12 16 views

答えて

0

を助けが必要

は、私は解決策を得ました。私はまだ引数を得ることができなかったので、サービスを作成し、すべてのタスクを取得し、一連のタスクをループしてループ内でタスクファイルを取得し、そのXMLファイルを読み込みました。仕事私は働いています。

Friend Function listTask() As DataTable 
    Dim dtTasks As New DataTable 
    dtTasks.Columns.Add("NAME") 
    dtTasks.Columns.Add("STATE") 
    dtTasks.Columns.Add("ARGS") 

    Dim service 
    service = CreateObject("Schedule.Service") 
    Call service.Connect() 

    ' Get the task folder that contains the tasks. 
    Dim rootFolder 
    rootFolder = service.GetFolder("\") 

    Dim taskCollection 'As Microsoft.Win32.TaskScheduler.TaskCollection 
    taskCollection = rootFolder.GetTasks(0) 

    Dim numberOfTasks As Integer 
    numberOfTasks = taskCollection.Count 


    If numberOfTasks = 0 Then 
     MsgBox("Não Existem Tarefas") 
    Else 
     Dim count As Integer = 0 
     Dim registeredTask 
     For Each registeredTask In taskCollection 
      'For i = 0 To numberOfTasks - 1 
      Dim taskState As String 
      Select Case registeredTask.State 
       Case "0" 
        taskState = "Unknown" 
       Case "1" 
        taskState = "Disabled" 
       Case "2" 
        taskState = "Queued" 
       Case "3" 
        taskState = "Ready" 
       Case "4" 
        taskState = "Running" 
      End Select 
      'TENHO AQUI TUDO !!!!! 
      Dim aaaa As String = registeredTask.xml 

      Dim BodyDoc As XmlDocument = New XmlDocument() 
      BodyDoc.LoadXml(aaaa) 
      Dim ReaderDoc As XmlNodeReader = New XmlNodeReader(BodyDoc) 

      'TENTAR METER NO DATASET 
      Dim ds As DataSet = New DataSet() 

      ds.ReadXml(ReaderDoc) 
      ReaderDoc.Close() 


      dtTasks.Rows.Add() 
      dtTasks.Rows(count).Item("NAME") = ds.Tables("RegistrationInfo").Rows(0).Item("URI").ToString 
      dtTasks.Rows(count).Item("STATE") = taskState.ToString 
      Dim column As DataColumnCollection = ds.Tables("Exec").Columns 
      If column.Contains("Arguments") Then 
       dtTasks.Rows(count).Item("ARGS") = ds.Tables("Exec").Rows(0).Item("Arguments").ToString 
      Else 
       dtTasks.Rows(count).Item("ARGS") = "" 
      End If 
      count = count + 1 

     Next 
    End If 
    Return dtTasks 

End Function 
関連する問題