taskscheduler return next run time incorrect

Topics: Errors
Mar 13, 2014 at 12:15 AM
Hi,

I am tring to access task hosted at Europe located server but my code is running on US located server. I am geeting Last Run Time values correct for the task but Next Run time is geeting convert as per EST (US) timezone. Which is past date than last run time !!!

How to get the correct Next Run Time (as per Windows Task Scheduler showing on Europe Server)?

Please help!
Coordinator
Mar 13, 2014 at 3:33 PM
Interesting. Can you tell me what version of Windows you are running locally and on the remote server? In trying to troubleshoot, it will help me to know if this is a V1 vs. V2 problem or not. Also, if I understood correctly, you are getting the correct next run time value when you use the system Windows Task Scheduler tool. If that is right, what steps are you taking to connect and then discover that value?
Mar 13, 2014 at 3:59 PM
Edited Mar 13, 2014 at 4:00 PM
Hi,

Windows Version for both the servers is Windows Server R2.
Yes, I am getting the correct next run time value when you use the system Windows Task Scheduler tool, but when I am using below code it to get the Next Run time it is converting as per EST (US) timezone.

TaskScheduler.Task task;
//some code here to initilize task object.
task.NextRunTime.ToString();

Result:

Last Run Time
3/13/14 4:30 PM

Next Run Time
3/13/14 11:40 AM

Next Run Time is showing as per (EST) it should be 3/13/14 4:40 PM. In Windows Task Schdule on Europe server it is showing Next Run Time = 3/13/14 4:40 PM.

Please help!
Coordinator
Mar 14, 2014 at 1:51 PM
Just to be clear, when you get the time using the Windows Task Scheduler tool, are you connecting to the remote server using the system tool on your local machine? Similarly, are you running the code to connect to the remote server from your local machine? I'm trying to make sure the code is being called in the same way before troubleshooting.
Mar 14, 2014 at 3:53 PM
Hi,

To get time of task from Windows Task Scheduler of Europe server, i am doing Remote Desktop Connection and I can see Next Run Time as per Europe timining.

But When I am running above code from my US Server and tring to get Next Run Time (of task from Windows Task Scheduler of Europe server) using below code I am getting, Next Run Time converted into EST timing.

TaskScheduler.Task task;
//some code here to initilize task object.
task.NextRunTime.ToString();


Would that help you to troubleshoot? Let me know for more information.
Coordinator
Mar 17, 2014 at 1:03 PM
That helps. Will you try and connect to the server in Europe from your local instance of the Windows Task Scheduler tool (Actions | Connect to Another Computer) and then see if the time zone for next run time is incorrect? The reason I'm asking is that I am only pulling the value directly from the native library and need to know if the library or my wrapper is causing the problem.
Mar 17, 2014 at 1:26 PM
I tried to connect to Europe server using remote desktop connection and the Next Run Time in task scheduler is showing correct. But while pulling Bext Run Time using code it is showing incorrect (in EST).
Coordinator
Mar 18, 2014 at 12:06 AM
I understand. However, I'm asking you to connect to the European server using the local Windows Task Scheduler tool. It will then use the same native call to get the next run time remotely that my library is using. If they both return the same time, then I know the problem is in the native library. By doing what you have done, you are always calling the library locally (which I know works consistently).
Marked as answer by dahall on 9/1/2015 at 10:08 AM