Solved

Trying to Programmatically Stop Task Scheduler - "System Error 5 has occured"

Posted on 2013-11-04
1
1,354 Views
Last Modified: 2013-11-04
I am simply trying to execute a C# program that will run a "net stop schedule" from the command line (basically I need to stop the scheduled tasks briefly while this code executes and then re-start afterwards).

Starting an elevated or normal command prompt and typing this command manually results in this output:

System error 5 has occurred.

Access is denied.

Open in new window


I've seen some fixes on the internet about changing a registry value from 2 to 4 but that completely disabled the service and wouldn't allow it to start.

Any ideas?
0
Comment
Question by:street9009
1 Comment
 
LVL 54

Accepted Solution

by:
McKnife earned 500 total points
ID: 39622393
Easy: that command needs to be run as system, not as administrator. So elevation alone is not enough. Running as system can be achieved using
psexec -s -i net stop schedule
for example.
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will review the basic installation and configuration for Windows Software Update Services (WSUS) in a Windows 2012 R2 environment.  WSUS is a Microsoft tool that allows administrators to manage and control updates to be approved and ins…
A safe way to clean winsxs folder from your windows server 2008 R2 editions
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
This tutorial will walk an individual through the process of installing of Data Protection Manager on a server running Windows Server 2012 R2, including the prerequisites. Microsoft .Net 3.5 is required. To install this feature, go to Server Manager…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question