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

TaskScheduler to access task from a "WORKGROUP" machine

Topics: Errors, Setup
May 7, 2014 at 5:10 AM
I am using the Win32.TaskScheduler to run Windows Scheduled Tasks from my web application as mentioned in this thread.

Now the difficulty I am facing is the machine which has the tasks scheduled is not in a network domain. (Since My Computer -> Properties shows something like Workgroup : WORKGROUP) and my web application is throwing an error in this line

TaskService tasksrvc = new TaskService(server.Name, login, domain, password);

So if the machine is in a WorkGroup, this task scheduler will not work? . If its possible, can somebody help me with how to specify the target server, username, domain values in case of a work group machine?
May 7, 2014 at 3:26 PM
It will work, but the account running the code (usually a specific IIS account) needs to be a member of the Backup Operators or Administrators group. If this account has those rights, then when connecting to the TaskService, you do not need to supply any parameters.
May 9, 2014 at 7:21 AM
Hi dahall,

I guess I didn't explain the scenario correctly. The web application and the scheduled tasks are actually running in different machines. The machine which runs the scheduled tasks is a WORKGROUP machine as I have mentioned in my earlier post. So in this scenario, how can I remotely run the scheduled tasks using this Win32.TaskScheduler from my web application which is running in another machine and it will be helpful if you can give some sample code to illustrate how I can specify all those parameters esp the targetServer, domain, username.

May 9, 2014 at 5:10 PM
Ok. When you instantiate the TaskService object, you will need to use the parameters allowing you to connect remotely (see Documentation for example code). You will only need to specify a valid Administrators or Backup Operators account on the remote WORKGROUP machine. For the user's domain name, use the remote machine's name.
May 10, 2014 at 4:30 PM
Hi dahall,

Thanks again for your support.

Please have a look into the specs of my server machine

Machine name : develop100
User name : sysadmin (this is the Admin account)
Workgroup : WORKGROUP

Here is the code I tried

TaskService tasksrvc = new TaskService(develop100, sysadmin, develop100, mypassword);

As you mentioned I have given the remote machine name (develop100) as the domain name, still i am getting an exception. Please help. Do you find any mistake in the code I tried?
May 11, 2014 at 3:40 AM
That is the correct syntax. You may have firewall issues on develop100 that are preventing access.
May 12, 2014 at 8:23 AM
Hi dahall,

I don't think this exception has something to do with the Windows Firewall. I have asked our System Admin to turn off the Windows Firewall in develop100 and then I tried, still ended up with the same exception "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))".

After researching a lot on this issue, I saw an article which states "You can use this only when the local and remote computers are in the same domain or the local computer is in a domain that the remote computer domain trusts. Otherwise, the remote computer cannot authenticate the user account specified and it cannot verify that the account is a member of the Administrators group." (Unfortunately I cannot ask the admin to set up a domain for me just for this requirement :( )

Can this be the reason?