0
votes

5893.1

Hi all,

I have searched and got answers for my questions many times from this forum. However, I now have a question that I don't think anyone has asked before.

We use Windows DOS batch to compact MS Access 2010 DB files everyday. It seems Access does not pass any return code to DOS. So my question is: Is there a way to tell whether the compacting is successful or not from within the batch?

We use Win XP/7 machines for development, and Windows Server 2008 for production. We are running MS Access 2010.

The DOS batch has a line like "D:\Microsoft Office\Office14\msaccess.exe" %DBLoc%%BkupFile% /compact %DBLoc%%DBFile%

Any help is much appreciated.

1

1 Answers

1
votes

Doesn't appear that there is a return code.

However, one time-tested technique is to pipe the output from the command to a text file and then test the contents of the text file. That way, if there's an error message printed at least you'll be able to catch that.

eg. add ' > test.txt' to the end of the command line.

You'd have to check on the available command shell tools to read the text.

You may also have to specifically redirect the error output separately from the command output. see here for redirection info : http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/redirection.mspx?mfr=true

Edit: to head off the next question, some links on detecting the failure message in the text file

http://ss64.com/nt/findstr.html

How to set variable with the result of findstr