• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 368
  • Last Modified:

Scheduled BAT Job on Windows Server Running But Not Executing Commands

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?

  • 2
1 Solution
stargazerm31Author Commented:
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.

pushd "c:\your_directory"

at the beginning of your script
MichaelSystems EngineerCommented:
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.
stargazerm31Author Commented:
Thanks for the code.  That did it.

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now