程序从 Windows 手动启动 调度程序运行两次

Program started manually from Windows Scheduler runs twice

使用 Windows Server 2012。我有一个 Windows 调度程序任务,在每个月的第 10 天 运行 执行一个程序。 这最近开始发生,我不明白为什么:当我从 Windows 调度程序手动 运行 它时,它启动两次(见图)

无法理解发生了什么,我查看了代码,它是一个以 Sub Main(args() as String) 开头的 .Net 控制台应用程序。我没有传递任何参数,Sub Main 中没有任何东西会触发重启.... 请指教

这是 Sub Main() 中的代码

Sub Main(args As String() = Nothing)
   Dim inputFile As String, sErr As String = vbNullString, bOk As Boolean = 
  True
  Dim ID As Integer, currentRow As String = Nothing, sLogFilePath As String 
 = vbNullString, sNewName As String = vbNullString, i As Integer
Dim bDownloadData As Boolean = True
Dim watch As Stopwatch = Stopwatch.StartNew()
If args.Count > 0 Then bDownloadData = CBool(args(0))

If bDownloadData Then
  'run P6 report to get list of Active Reports
  sLogFilePath = P6_PATH & "myLog.txt"
  Console.WriteLine("Get list Of active projects")
  ID = Shell(P6_PATH & "runbatch_Active_Projects.bat", AppWinStyle.NormalFocus, True, -1)
  Console.WriteLine("Active Projects extract/P6 Client Return code: " & ID & vbCrLf)

  'read myLog.txt to see if completed without errors
  If File.Exists(sLogFilePath) Then
    Using MyReader As New StreamReader(sLogFilePath, Encoding.Default)

      While Not MyReader.EndOfStream
        'read current row until the last
        currentRow = MyReader.ReadLine
      End While
      MyReader.Close()
      MyReader.Dispose()
    End Using

    If InStr(1, currentRow, "Returning Exit Code: 0", CompareMethod.Text) = 0 Then
      Console.WriteLine("An error has occurred extracting Active Projects: " & currentRow)
      SendMail1("Active Projects extraction error", currentRow)
      Exit Sub
    End If
  End If
End If

ReadExcelFile ("BWMP_main.xlsx")
SendMail1("Success)"
End Sub

这是怎么回事;执行以下代码行:

 SendMail1("Active Projects extraction error", currentRow)

然后我收到了一封包含错误代码的电子邮件,但是...程序只是重新启动并毫无问题地执行到最后,这行代码也执行了:

   SendMail1("Success)"

所以我最终收到了两封电子邮件:一封报告错误,另一封报告成功。很奇怪...

我正在回答我自己的问题,以防有人遇到同样的问题。 我刚刚删除了 Windows 调度程序作业并重新创建了它。问题消失了。奇怪...