문제

Is it possible for a VB.Net script to determine if it was launched manually or by Task Scheduler?

In my attempts to research this question, I could only find problems people were having with their scripts when launched by Task Scheduler, or how to create scheduled tasks in VB.

도움이 되었습니까?

해결책

The easiest solution to this would be to configure the scheduled task to pass in a command line parameter to let the application know who launched it. For example, pass in "SCHEDULER" on the command line and then check for that command-line parameter in your code, as such:

    For Each s As String In My.Application.CommandLineArgs
        If s = "SCHEDULER" Then
            '' do stuff here
        End If
    Next 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top