Solved

How to get Task Scheduler to run BAT correctly

Posted on 2014-09-23
3
360 Views
Last Modified: 2014-09-23
Hello,

I have a scheduled task to run a BAT file that is suppose to delete some files at 9:00 PM daily.  The OS is Windows Server 2012.  The task starts and runs with the account that the task is using.  I have logged into the server with a different account and scheduled a time for it to start and it starts and the BAT deletes the files.  So, all is good. However, when no one is logged into the server and when 9:00 PM comes around the task starts, but the del command in the BAT fails to delete the files.  I have set the task to "Run with highest privileges"  and run whether user is logged on or not.  But, the del command does not remove the files.   Here is the del command:

del \\server\d$\SQL-Backups\*.bak /f /q

Any ideas on what could be going on?

Thanks
0
Comment
Question by:PBIT
3 Comments
 
LVL 16

Accepted Solution

by:
Brian Pringle earned 500 total points
ID: 40339841
You need to explicitly give the user account that is set to run the task full control file permissions to the folder containing the batch file, as well as the batch file itself.  For some reason, user group membership does not propagate unless the user is logged in.
0
 
LVL 33

Expert Comment

by:it_saige
ID: 40339876
Also ensure that the user is given the permission; "Log on as a batch job" in the Local Computer Policy -> Security Settings -> User Rights Assignment.

-saige-
0
 

Author Comment

by:PBIT
ID: 40339917
Ok I will check both of these things.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Static IP Address Assignment 10 72
Server 2012 ADMX 1 22
How to properly configure _msdcs child zone? 14 28
Application timeout 4 36
The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
In this Micro Tutorial viewers will learn how they can get their files copied out from their unbootable system without need to use recovery services. As an example non-bootable Windows 2012R2 installation is used which has boot problems.
This tutorial will walk an individual through the process of configuring basic necessities in order to use the 2010 version of Data Protection Manager. These include storage, agents, and protection jobs. Launch Data Protection Manager from the deskt…

679 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