If you have a .BAT file and are trying to get it to start automatically using the Windows Task Scheduler, you may have encountered an issue where it just won’t start unless you manually start the task.
I created a batch file that deletes everything inside the temp folder when the computer starts up. I created a simple task in Task Scheduler and hoped for the best. Unfortunately, nothing happened when I booted my computer. After a lot of trial and error, I figured out how to run the script.
In this article, I will walk you through the settings and permissions that need to be changed in order for your batch file to work without manual intervention.
Step 1: Check the file / folder permissions
The first step in fixing this issue is to ensure that the account you use to run the script in Task Scheduler has Full Control permissions to the folder containing the script, the script itself, and any folders / files that the script touches upon startup.
For example, I created the following batch script below:
set folder = “C: test” cd / d% folder% for / F “delims =” %% i in (‘dir / b’) do (rmdir ” %% i “/ s / q || del” %% i “/ s / q)
I saved the .BAT file in the Documents folder. Path: C: Users username Documents. I went to C: Users username, right-clicked the Documents folder and selected Properties. Then I went to the Security tab.
As you can see, the Aseem user account has been explicitly added and granted Full Control permission. Now you need to do the same for the folder containing the script and for the script itself. Don’t assume that if you give permissions to the folder containing the script, you will be fine, because it is not. Finally, set permissions for any files and folders that the script will interact with.
In my case, I had to go to C: test, right click on that folder and add my account there with “Full Control” permissions. It’s a little annoying that you have to do this, but it’s the only way to run the script.
Note. The account used to run the script must be a member of the local Administrators group on the computer. In my case, the Aseem account is an administrator account and therefore part of the local Administrators group.
Second Step: Check the Task Scheduler settings
Now let’s go to the Task Scheduler and change the corresponding settings there. Open Task Scheduler and find your task under Active Tasks. They should be listed in alphabetical order.
Double click on it and the task will open in the same window. To edit a task, you need to right-click it and select Properties.
There are several tabs and a couple of things need to be checked and changed here. First, on the General tab, you need to check the user account that is used to run the task. In my case, this is the Aseem account that I previously gave file system permissions to and which is part of the Administrators group on the computer.
Then you need to select the Run regardless of whether the user is logged in or not option and select Windows Vista, Windows Server 2008 in the Configure for box.
On the Actions tab, select the script, click Modify, and then add the path to the folder containing the script in the Start In (Optional) box. It may seem unnecessary, but it is not. In my case, I put in the field C: Users Aseem Documents .
Now click OK to save the settings. When you do this, a dialog box may appear where you will need to enter the password of the user account that will run the task. This brings up another requirement. You cannot use an account that does not have a password. The user account must have a password to run the task.
Finally, you must manually start the task once in the Task Scheduler to make sure it is running. If after you change all the settings, it works fine manually, it should start when it should. In my case, it should have happened on startup, and after I made the changes, everything worked.
Note that if your script at startup refers to different computers in the domain, you should try to use a domain administrator account to run the task. This ensures that the account has sufficient permissions to access remote computers.
Another point to watch out for is if your script is accessing resources on a network share. If your script uses letters to access the network, it may not work. For example, instead of using F: data , you should use \ machinename share_name data in the script. If you still can’t run the script, please leave a comment here and I’ll try to help. Enjoy!