Fix Scheduled Task Won’t Run for .BAT File
We’ll walk you thru all the steps and settings
If you have a .BAT file and you’re trying to get it to run automatically using Task Scheduler in Windows, you might have run into the issue where it simply doesn’t run unless you manually run the task.
I created a batch file that deletes everything inside a temp folder whenever the computer starts up. I created a basic task in Task Scheduler and hoped for the best. Unfortunately, nothing happened when my computer booted up. After a lot of trial and error, I figured out how to get the script to run.
In this article, I’m going to walk you through the settings and permissions you need to adjust in order to get your batch file to run without manual intervention.
Step 1: Check File/Folder Permissions
The first step to fixing this issue is ensuring that the account you are using to run the script in Task Scheduler has Full Control permissions on the folder containing the script, the script itself, and any folders/files that the script touches when it runs.
For example, I created the following batch script below:
I saved the .BAT file to my Documents folder. The path isC:\Users\username\Documents. I went to C:\Users\username, right-clicked on theDocumentsfolder, and clicked onProperties. Then I clicked on theSecuritytab.
As you can see, the user accountAseemhas been explicitly added and given theFull Controlpermission. Now you have to do the same thing for the folder that contains the script and for the script itself. Don’t just assume that if you give permissions to the folder containing the script, you’re good to go, because you’re not. Lastly, set permissions on any files and folders that the script will interact with.
In my case, I had to go toC:\test, right-click on that folder and add my user account there with Full Control permissions. It’s kind of annoying that you have to do this, but it’s the only way to get the script to run.
Note: The account that is being used to run the script has to be part of the localAdministratorsgroup on the computer. In my case, the Aseem account is an administrator account and therefore part of the local Administrators group.
Step 2: Check Task Scheduler Settings
Now let’s go to Task Scheduler and change the appropriate settings there. Open Task Scheduler and find your task under theActive Taskssection. They should be listed out in alphabetical order.
Double-click on it and it’ll open the task by itself in the same window. In order to edit the task, you’ll have to right-click on it and chooseProperties.
There are several tabs and a couple of things have to checked and changed here. Firstly, on theGeneraltab, you need to check the user account that is being used to run the task. In my case, it’s theAseemaccount, which I had given permissions to earlier on the file system and which is part of the Administrators group on the computer.
Next, you have to choose theRun whether user is logged on or notoption and chooseWindows Vista, Windows Server 2008in theConfigure forbox.
On theActionstab, you have to select the script, click onEditand then add in the path to the folder containing the script in the Start in (optional)box. This may seem unnecessary, but it’s not. In my case, I put inC:\Users\Aseem\Documents\in the box.
Now click onOKto save the settings. When you do this, a dialog may appear where you have to enter the password for the user account that will run the task. This brings up another requirement. You can’t use an account that doesn’t have a password. The user account has to have a password in order for the task to run.
Lastly, you should run the task manually once in Task Scheduler to make sure it runs. If it runs fine manually after you changed all the settings, then it should run when it’s supposed to be triggered. In my case, it was supposed to happen on startup and after I made the changes, everything worked fine.
Note that if your script is accessing different computers in a domain when run, you should try to use the domain administrator account to run the task. This will ensure the account has enough permissions to access the remote computers.
Another item to note is if your script accesses resources on a network share. If your script is using letters to access the network, it may not run. For example, instead of usingF:\data, you should use\machinename\share_name\data\in the script. If you still can’t get your script to run, post a comment here and I’ll try to help. Enjoy!
Founder of Help Desk Geek and managing editor. He began blogging in 2007 and quit his job in 2010 to blog full-time. He has over 15 years of industry experience in IT and holds several technical certifications.Read Aseem’s Full Bio
Leave a Reply
Your email address will not be published.Required fields are marked*
Comment*
Name*
Email*
Website
Welcome to Help Desk Geek- a blog full of tech tips from trusted tech experts. We have thousands of articles and guides to help you troubleshoot any issue. Our articles have been read over 150 million times since we launched in 2008.
HomeAbout UsEditorial StandardsContact UsTerms of Use
Copyright © 2008-2024 Help Desk Geek.com, LLC All Rights Reserved