Scheduled BAT Job on Windows Server Running But Not Executing Commands

Posted on 2011-04-25
Last Modified: 2012-05-11
Hello all,

I have a strange one.  I have a Windows 2003 Server Standard Edition that has a Bat job that sets the drive letter, changes a directory and then DEL *.txt.  When I double click on the BAT job, it executes just fine.  No issues and it deletes everything in the directory.  When I schedule the BAT job, it acts like it runs.  Does not give me any error, but it does not delete the files.

Any idea why?

Question by:stargazerm31

    Author Comment

    Interesting.  I commented out the DEL and added a DIR *.txt >> file.txt and it appears that it is not remembering the setting for directory letter and not changing directory because it is executing the DIR in the directory of the BAT file.  I still don't have a great answer for how to do this.
    LVL 4

    Accepted Solution


    pushd "c:\your_directory"

    at the beginning of your script
    LVL 3

    Expert Comment

    Another thing is, you may have to run the job as an administrator. There is a setting in the Scheduled Jobs area to input this.

    Author Closing Comment

    Thanks for the code.  That did it.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    by Batuhan Cetin In this article I will be guiding through the process of removing a failed DC metadata from Active Directory (hereafter, AD) using the ntdsutil tool in a Windows Server 2003 environment. These steps are not necessary in a Win…
    A quick step-by-step overview of installing and configuring Carbonite Server Backup.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    759 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