Solved

How to get Task Scheduler to run BAT correctly

Posted on 2014-09-23
3
354 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
Comment Utility
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 32

Expert Comment

by:it_saige
Comment Utility
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
Comment Utility
Ok I will check both of these things.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In my previous Experts Exchange Articles (http://www.experts-exchange.com/ARTH_1864316.html?arthOrderBy=3&arthSort=1#arth), most have featured Basic and Intermediate VMware Topics.  As a Virtualisation Consultant, we implement many different virtual…
You might have come across a situation when you have Exchange 2013 server in two different sites (Production and DR). After adding the Database copy in ECP console it displays Database copy status unknown for the DR exchange server. Issue is strange…
In this Micro Tutorial viewers will learn how to restore single file or folder from Bare Metal backup image of their system. Tutorial shows how to restore files and folders from system backup. Often it is not needed to restore entire system when onl…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now