?
Solved

How to get Task Scheduler to run BAT correctly

Posted on 2014-09-23
3
Medium Priority
?
368 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 16

Accepted Solution

by:
Brian Pringle earned 2000 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 34

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
A procedure for exporting installed hotfix details of remote computers using powershell
In this Micro Tutorial viewers will learn how to use Windows Server Backup to create full image of their system. Tutorial shows how to install Windows Server Backup Feature on Windows 2012R2 and how to configure scheduled Bare Metal Recovery backup.…
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…
Suggested Courses

770 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