Fix Scheduled Task Won’t Run for .BAT File
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:
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 to my Documents folder. The path is C:\Users\username\Documents. I went to C:\Users\username, right-clicked on the Documents folder, and clicked on Properties. Then I clicked on the Security tab.

As you can see, the user account Aseem has been explicitly added and given the Full Control permission. 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 to C:\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 local Administrators group 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 the Active Tasks section. 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 choose Properties.

There are several tabs and a couple of things have to checked and changed here. Firstly, on the General tab, you need to check the user account that is being used to run the task. In my case, it’s the Aseem account, 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 the Run whether user is logged on or not option and choose Windows Vista, Windows Server 2008 in the Configure for box.

On the Actions tab, you have to select the script, click on Edit and 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 in C:\Users\Aseem\Documents\ in the box.
Now click on OK to 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 using F:\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!
Fix Scheduled Task Won’t Run for .BAT File的更多相关文章
- How to Create a Cron Job (Scheduled Task) for Your Website or Blog
How to Create a Cron Job (Scheduled Task) for Your Website or Blog by Christopher Heng, thesitewizar ...
- 【java异常】定时任务异常ERROR 20604 --- [ scheduling-1] o.s.s.s.TaskUtils$LoggingErrorHandler : Unexpected error occurred in scheduled task
2019-11-20 13:20:00.006 ERROR 20604 --- [ scheduling-1] o.s.s.s.TaskUtils$LoggingErrorHandler : Unex ...
- failed to create pid file /var/run/rsyncd.pid: File exists报错
[root@pcidata-jenkins ansible_playbooks]# ps aux|grep rsyncroot 1799 0.0 0.0 114652 480 ? ...
- How to run a batch file each time the computer loads Windows
https://www.computerhope.com/issues/ch000322.htm#:~:text=Press Start%2C type Run%2C and press Enter. ...
- 【java异常】Unexpected error occurred in scheduled task. java.lang.StackOverflowError: null
可能是栈溢出(StackOverFlow) 背景:我用定时器new东西 原因:频率太快了好像!
- Gradle Goodness: Rename Ant Task Names When Importing Ant Build File
Migrating from Ant to Gradle is very easy with the importBuild method from AntBuilder. We only have ...
- bat file handling, main: echo type *.txt >> />
echo.@.call.pause.rem(小技巧:用::代替rem)是批处理文件最常用的几个命令 echo 表示显示此命令后的字符 echo off 表示在此语句后所有运行的命令都不显示命令行本身 ...
- win10家庭版,双击bat文件无法运行(double click bat file does not execute)
win10家庭版,双击bat文件无法运行,弹出文件打开方式选择框. 在网上搜索处理办法,试了以下方法1-5都没有成功,用方法6规避. 方法1:打开一个驱动器,点“工具-文件夹选项→文件类型→新建→扩展 ...
- linux bash shell run ros launch file and multi_node
#!/bin/bash #source /opt/ros/melodic/setup.bash #source /home/pi/catkin_ws/devel/setup.bash #ROS_PAC ...
随机推荐
- [BTS] BizTalk WCF-SQL Adapter 高级应用
9102年岁尾,41岁的我居然还在搞 BizTalk,感觉就是一种悲伤. 国内用户少之又少,能坚持一直在使用的“忠实”用户那就更少了. 不是它不好用,而是微软全线转向云服务,这个产品也已经快10年没有 ...
- Telerik JustDecompile
Free. For everyone. Forever. With an open source decompilation engine https://www.telerik.com/produc ...
- JavaScript如何封装插件
什么是封装呢? 我的理解就是 把一个功能单独做成一个组件,就像做饺子,以前做饺子必须自己先用面粉做饺子皮,再做饺子馅,然后再手工包饺子,但是现在人们发明了自动包饺子机器,虽然机器里面的每一步骤和你自己 ...
- mybatis之动态SQL操作之删除
/** * 持久层 */ public class StudentDao { /** * 动态SQL--删除 */ public void dynaSQLwithDelete(int... ids) ...
- Handle的特点
handler可以分发Message对象和Runnable对象到主线程中, 每个Handler实例,都会绑定到创建他的线程中(一般是位于主线程), 也就是说Handler对象初始化后,就默认与对它初始 ...
- nginx配置, 启动命令, 反向代理配置
2014年1月3日 13:52:07 喜欢这样的风格,干货 http://huoding.com/2013/10/23/290 -----------------下边是我自己的经验(windows)- ...
- vue 组件属性props,特性驼峰命名,连接线使用
网址:https://www.cnblogs.com/alasq/p/6363160.html 总结如下:vue的组件的props属性支持驼峰命名,不支持连接线命名,使用是用连接线进行赋值或者数据绑定 ...
- Web实现前后端分离,前后端解耦
一.前言 ”前后端分离“已经成为互联网项目开发的业界标杆,通过Tomcat+Ngnix(也可以中间有个Node.js),有效地进行解耦.并且前后端分离会为以后的大型分布式架构.弹性计算架构.微服务架构 ...
- phoenix创建表失败:phoenixIOException: Max attempts exceeded
下面的问题,搞了1天才解决,太坑了,在这里记录一下. 问题现像:执行命令后,1分钟没有返回, 然后报下面的错,偶尔会出现以下不同的报错信息. jdbc:phoenix:10.0.xx.1:2181&g ...
- idea设置背景色和字体大小
修改背景色 点击[File],选择[Settings]. 点击[Editor],选择[color Scheme]. 默认Scheme只有两种.Default是白色,Darcula是黑色 修改字体 ...