Solved

How to get Task Scheduler to run BAT correctly

Posted on 2014-09-23
3
357 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Server 2012 R2 TLS 1.2? 2 40
Exchange Management Shell dysfunctional - 0x8009030e 24 44
2012 R2 - strange boot OS setup 3 21
Changing passwords 3 21
My GPO's made for 2008 R2 servers were not allowing me to RDP into a new 2012 server by default.  That’s why I tried to allow RDP via Powershell, because I could log into a remote shell without further configuration. Below I will describe how I wen…
Resolve DNS query failed errors for Exchange
This tutorial will walk an individual through the process of installing the necessary services and then configuring a Windows Server 2012 system as an iSCSI target. To install the necessary roles, go to Server Manager, and select Add Roles and Featu…
This tutorial will walk an individual through the process of installing of Data Protection Manager on a server running Windows Server 2012 R2, including the prerequisites. Microsoft .Net 3.5 is required. To install this feature, go to Server Manager…

772 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