Jon
Jon

Reputation: 1209

Determine if Script was Launched Manually or by Task Scheduler

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.

Upvotes: 1

Views: 650

Answers (1)

DWRoelands
DWRoelands

Reputation: 4940

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 

Upvotes: 2

Related Questions