How to Fix: Schtasks /create /sc onlogon gives me an error
Error creating task on logon using schtasks, access denied.
📋 Table of Contents
The error 'Access is denied' when trying to create a task that starts up when the user logs on using the `schtasks /create` command can be frustrating for IT administrators and users alike. This issue typically affects users who are trying to automate tasks that require interaction with the operating system or specific applications.
This problem can occur due to various reasons, including insufficient permissions, incorrect user credentials, or conflicting system settings. In this guide, we will walk you through the steps to troubleshoot and resolve this issue.
🛑 Root Causes of the Error
- The primary reason for this error is that the `schtasks` command requires elevated privileges to execute tasks with `ONLOGON` scheduling. When you try to create a task using `schtasks /create`, it attempts to run under the context of the current user, which may not have sufficient permissions to perform certain actions.
- Another possible cause is that the user credentials provided are incorrect or do not match the actual username and password used by the system. This can lead to authentication failures and result in an 'Access is denied' error.
✅ Best Solutions to Fix It
Elevating Privileges using Runas
- Step 1: Open a Command Prompt as an administrator: Press the Windows key + X and select Command Prompt (Admin). Alternatively, you can search for 'Command Prompt (Admin)' in the Start menu.
- Step 2: Run the `schtasks /create` command with elevated privileges using the `runas` command: Type the following command and press Enter - `runas /user:jdl schtasks /create /sc ONLOGON /tn ComputerMonitor_LoginCheck /tr c:/users l est.bat`. Replace 'jdl' with your actual username, and '/users/rl/test.bat' with the path to the batch file you want to run.
Using Task Scheduler to Create a Task
- Step 1: Open Task Scheduler: You can do this by searching for 'Task Scheduler' in the Start menu or typing `taskschd.msc` in the Run dialog box (Windows key + R).
- Step 2: Create a new task: In the Task Scheduler, click on 'Create Basic Task' in the right-hand Actions panel. Give your task a name and description, then click 'Next'.
💡 Conclusion
To resolve the 'Access is denied' error when trying to create a task that starts up when the user logs on, you can try elevating privileges using `runas` or use Task Scheduler to create a task. If you are still experiencing issues, ensure that your user credentials are correct and check for any conflicting system settings.
❓ Frequently Asked Questions
🛠️ Related Fixes
How to Fix: Pc crashes shortly after launching game (rainbow
Fix Pc crashes shortly after launching game (rainbow six siege). Compl
How to Fix: Installing an APK on a locked down phone
Installing an APK on a locked down phone: Try using a rooted device, e
How to Fix: New PC build- no signal and no clue
Fix New PC build- no signal and no clue. Complete troubleshooting guid