Quantcast
Channel: Task Scheduler Managed Wrapper
Viewing all articles
Browse latest Browse all 2206

New Post: How to disable task scheduler in c#

$
0
0
Hi all,

Hope doing well,
sir i am writing a code where i need to disable the particular task in task scheduler.
Here is my code:

string taskName = "Device";
        TaskService ts = new TaskService(@"\\VIKASH", "VICKY", "VIKASH", "securax", true);
        using ( ts = new TaskService())
        {

            Task t = ts.GetTask(taskName);
            if (t != null)
            {
                if (t.Enabled)
                {
                    t.Enabled = false;
                    t.RegisterChanges();
                }
            }
        }
but getting error in this line " t.Enabled = false;"
Error is Access is denied Exception from HResult: 0x80070005 (E_AccessDenied)

how to disable it?
Thanks

Viewing all articles
Browse latest Browse all 2206

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>