Let’s say I have multiple scheduled tasks running at different times, but all of which are running a common Windows batch file. This batch file in turn executes a Java program.
I would like my batch file to get the name of the scheduled task that’s calling it, and pass its name to the program that my batch is executing. How can I do this?
Like Joey said there is no way to do it without getting help from outside.
You could create a separate instance of the batch for each task with an argument in each one specifying which task is assigned to run it.
You could also create smaller batches like this one:
and that would pass the name of your first task into the batch as the
%1variable.You could also have your batch figure it out based on the time that it was run using the
%time%variable, but this would need some parsing I’m sure as you can’t always guarantee it runs at the same time down to the second.it might look something like this:
and so on
(That last one assumes that your tasks only run at specified times during the day… and if for some reason they execute at a different time this won’t work)