This project has moved and is read-only. For the latest updates, please go here.

No task found when running on remote Windows Server 2008 R2 from Windows Server 2003 R2

Topics: Errors, Setup
Jan 16 at 3:02 PM
Hello,

I am having an issue with getting list of task (or certain task).
When running application on Server 2003 and trying to get list of all task from remote server 2008 it returns empty list of tasks. Of course, in case of finding task by name it returns null.
I am using .NET 4.0.
I tried both V1 and V2 mode but without expected results.

From other side, all works perfectly when I try to get this list (or certain task) with Win 10 machine to the same remote Windows Server 2008.

Below is a code which I use for getting tasks.
    private bool RunTaskViaTaskScheduler(bool isV1 = false)
    {
        string password = "adminUserPasswordForTaskScheduler";
        string serverName = "remote-server";
        string login = "adminUserForTaskScheduler";
        string domain = "DOMAIN";
        string taskName = "RemoteTask";
        string tasksNames = string.Empty;

        try
        {
            using (TaskService tasksrvc = new TaskService(serverName, login, domain, password, isV1))
            {
                if (tasksrvc == null)
                {
                    return false;
                }

                Task task = tasksrvc.FindTask(taskName);     //this line returns null

                //made for testing purposes
                foreach (Task temp in tasksrvc.AllTasks)     //this enumerator has no elements
                {
                    tasksNames += temp.Name + ";";
                }
                lblInfo.Text = tasksNames;
                
                if (task == null)
                {
                    return false;
                }
                else
                {
                    //some code here    
                }
            }
        }
        catch (Exception ex)
        {
            lblInfo.Text = "Error occurred in RunTaskViaTaskScheduler " + ex.Message + ex.StackTrace;
            return false;
        }
        return true;
    }
Any suggestion what am I doing wrong?

Thank you in advance
Jan 18 at 10:10 AM
Hello again,

Finally, I found out what was wrong.
Problem was with tasks made in task scheduler on remote machine, all of them are V2 compability.
What I did was recreating those tasks with V1 compability (Create New Task -> in first tab for combobox 'Configure for' choose option 'Windows Server 2003, Windows XP, or Windows 2000').

Discusion from this topic https://taskscheduler.codeplex.com/discussions/405210 helped me with locating my mistake.

Hope those information will be usefull for somebody.

Greetings
Marked as answer by dahall on 1/18/2017 at 7:38 AM