Batch File Not Running

Experts,

I have a DOS batch file that I use to run nightly backups to a USB key.  I have "sub" batch files in a child directory that are called from the main batch file (attached).  

When I attempt to call these "sub" batch files, I get an error saying they are "not recognized as an internal or external command".  

What's going on?
REM Copies from computer to USB key



REM Get rid of all .obj files.
Call "C:\Program Files\MyBatchFiles\utility\DeleteFilesByExtension.bat" "C:\Documents and Settings\cemich\My Documents\My Desktop Apps\Knowledge Tracker\" "*.obj"


REM Get rid of all .log files.
Call "C:\Program Files\MyBatchFiles\utility\DeleteFilesByExtension.bat" "C:\Documents and Settings\cemich\My Documents\My Desktop Apps\Knowledge Tracker\" "*.log"


REM Get rid of all .tmp files.
Call "C:\Program Files\MyBatchFiles\utility\DeleteFilesByExtension.bat" "C:\Documents and Settings\cemich\My Documents\My Desktop Apps\Knowledge Tracker\" "*.tmp"



REM Get rid of all KT databases over six weeks old.
Call "C:\Program Files\MyBatchFiles\utility\DeleleteMDBsOverSixWeeksOld.bat"




REM Get rid of all executables before a given date.
Call "C:\Program Files\MyBatchFiles\utility\DeleleteEXEsOverSixWeeksOld.bat"



REM Delete the "My Desktop Apps" folder under \Knowledge Tracker if it exists.
RD "c:\Documents and Settings\cemich\My Documents\My Desktop Apps\Knowledge Tracker\My Desktop Apps"


GOTO END



REM Copy all desktop app files.
c:
cd\
cd "Documents and Settings\cemich\My Documents\My Desktop Apps"
xcopy *.* /S /Y /D /H /I "f:\Documents and Settings\cemich\My Documents\My Desktop Apps"



c:
cd\
cd "Documents and Settings\cemich\My Documents\Work"
xcopy *.* /S /Y /D /H /I "f:\Documents and Settings\cemich\My Documents\Work"



cd\
cd "CCSMultiClient\CCSAdvantageDB\My Scripts\Utility"
xcopy *.* /S /Y /D /H /I "f:\CCSMultiClient\CCSAdvantageDB\My Scripts\Utility"



cd\
cd "C:\Documents and Settings\cemich\My Documents\Visual Studio 2008\Projects"
xcopy *.* /S /Y /D /H /I "f:\Documents and Settings\cemich\My Documents\Visual Studio 2008\Projects"



cd\
cd program files
cd MyBatchFiles


:END

Open in new window

LVL 1
NigelRocksAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

t0t0Commented:
what happens when you enter the command:

   dir /a-d "C:\Program Files\MyBatchFiles\utility\DeleteFilesByExtension.bat"

does it list the batch file and show "1 File(s)"?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bill PrewIT / Software Engineering ConsultantCommented:
Based on the error, if it is happening on the CALL statment in the batch file you posted, then it sounds like the following files don't exist or can't be found.  Have you checked that they actually exist, and that you can view them?

"C:\Program Files\MyBatchFiles\utility\DeleleteEXEsOverSixWeeksOld.bat"
"C:\Program Files\MyBatchFiles\utility\DeleleteMDBsOverSixWeeksOld.bat"
"C:\Program Files\MyBatchFiles\utility\DeleteFilesByExtension.bat"

If they do exist, then I would check the actual command that is indicated in the error message.  Maybe there is a command or program being run from the BAT files you call that is getting the error on a different program?  You should be getting an error message like below, where the quoted item is the command or program that can not be found.  Is it always one of the 3 BAT files mentioned above, or is it something different?

'foo.bat' is not recognized as an internal or external command,

~bp
0
t0t0Commented:
billprew

>> "Have you checked that they actually exist..."

Hopefully, you'll recognise the relevance of the DIR command in the previous comment.

Oddly enough, you took the next suggestion right from beneath my fingertips - could the CALLed batch files themselve CALL a subsequent batch file which cannot be found...

0
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

NigelRocksAuthor Commented:
If the error message doesn't mean what it's saying, there ARE calls to an .exe within each of the .bat files (attached).
That file exists in \Windows\System32, so I'm not sure why it wouldn't be found.

DelDate.exe /Q /F C:\Documents and Settings\cemich\My Documents\My Desktop Apps\Knowledge Tracker\ /M ww /T 6 /W *.exe /L

Open in new window

0
Bill PrewIT / Software Engineering ConsultantCommented:
==> NigelRocks

A couple of follow up items:

When the error shows up, it should show the name of the command it was trying to execute, in your case what does it show?

In the DelDate command line you showed above, you would need to quote the pathname since it has spaces, like below.  I don't think this is the cause of the error, but wanted to pass it along.

DelDate.exe /Q /F "C:\Documents and Settings\cemich\My Documents\My Desktop Apps\Knowledge Tracker\" /M ww /T 6 /W *.exe /L

One other thought, since you are running the original script from the task scheduler, could it be a case where the user credentials being used by the scheduled task have a different PATH than you have logged in?  You could add a SET command all by itself at the top of the executed batch file to see what the PATH is when it runs, along with other environment variables.

For further help with this error, could you please supply the actual log file from the scheduled task execution.

~bp
0
NigelRocksAuthor Commented:
Where am I running it from the Task Scheduler?  I'm launching it manually at the command line.  Am I missing something?
I've attached what the command window looks like after I've launched the program.

image.bmp
0
Bill PrewIT / Software Engineering ConsultantCommented:
Sorry on task scheduler, somewhere thought that was the case, my bad.

Okay, from that screen shot I can see the following. The first three calls (below) found the BAT file called, but when that BAT file ran it didn't locate the files you passed it. I'd also think that there is an ECHO OFF at the top of that BAT file that stops all command echoing from that first call forward, you could remove that for now to get a look at the details. You will have to determine what is wrong with the paths to the LOG, OBJ and TMP files. Do a

DIR ""C:\Documents and Settings\cemich\My Documents\My Desktop Apps\Knowledge Tracker"
to see if any files show up.

Call "C:\Program Files\MyBatchFiles\utility\DeleteFilesByExtension.bat" "C:\Documents and Settings\cemich\My Documents\My Desktop Apps\Knowledge Tracker\" "*.obj"
Call "C:\Program Files\MyBatchFiles\utility\DeleteFilesByExtension.bat" "C:\Documents and Settings\cemich\My Documents\My Desktop Apps\Knowledge Tracker\" "*.log"
Call "C:\Program Files\MyBatchFiles\utility\DeleteFilesByExtension.bat" "C:\Documents and Settings\cemich\My Documents\My Desktop Apps\Knowledge Tracker\" "*.tmp"

Then on the next two calls the BAT files don't exist at the path specified. I suspect it's due to the typo in the middle of the word "Delelete" ?

Call "C:\Program Files\MyBatchFiles\utility\DeleleteMDBsOverSixWeeksOld.bat"
Call "C:\Program Files\MyBatchFiles\utility\DeleleteEXEsOverSixWeeksOld.bat"


~bp
0
NigelRocksAuthor Commented:
I thought I had fixed Delelete.
Anyway the path works fine with:
"C:\Documents and Settings\cemich\My Documents\My Desktop Apps\Knowledge Tracker"  
I copied DelDate.exe from \Windows\System32 to the same directory as the sub bat files, but it still doesn't work.

image.bmp
0
Bill PrewIT / Software Engineering ConsultantCommented:
Can you comment out the ECHO OFF in DeleteFilesBy Extension.bat and rerun, posting the results?  It appears to be running that BAT file okay, but somewhere in it generating the file not found error.

The error seems to indicate that it can't find the files:

"C:\Documents and Settings\cemich\My Documents\My Desktop Apps\Knowledge Tracker\*.obj"
"C:\Documents and Settings\cemich\My Documents\My Desktop Apps\Knowledge Tracker\*.log"
"C:\Documents and Settings\cemich\My Documents\My Desktop Apps\Knowledge Tracker\*.tmp"

~by
0
NigelRocksAuthor Commented:
Those errors are OK, because files with those extensions should be deleted anyway.
0
Bill PrewIT / Software Engineering ConsultantCommented:
Okay, then in that case everything seems to be resolved.  Is there still something else that isn't working the way you want / expected?

~bp
0
t0t0Commented:
thank you
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft DOS

From novice to tech pro — start learning today.