[Webinar] Learn how to a build a cloud-first strategyRegister Now


Executing DOS Batch file from Access and wait until DOS window has closed

Posted on 2009-04-27
Medium Priority
Last Modified: 2012-05-06
Hi Experts,

I'm calling a batch file from MSAccess and need to wait until the batch commands have finished.
The batch file ("DnLoadBeta.BAT") connects to an ftp server and executes a script file ("C:\ftp_Script_DnLoad.txt") which download big files.
I need to wait within Access until files have been downloaded (means: until the DOS window of batchfile "DnLoadBeta.BAT" has closed).

Batch file content (FileName: DnLoadBeta.BAT):
     ftp -s:"C:\ftp_Script_DnLoad.txt" ftp.MyFtpServer.com
Script file content (FileName: C:\ftp_Script_DnLoad.txt):
     cd users/JPRTL/BetaTool
     get "beta946.zip" "C:\ftp\Application\beta946.zip"

I'm currently calling the batchfile "DnLoadBeta.BAT" from MSAcess with this command:

How can I make MSAccess waiting for completion of Batchfile?

Thanks in advance
Question by:MartinNeubauer
LVL 10

Assisted Solution

therealmongoose earned 200 total points
ID: 24243181
One way to handle the "is the process finished yet? question would be to add an extra dummy very small text file to the ftp process which is downloaded last - get access to run a
do while dir("c:\temp\dummyfile.txt") = ""
To keep checking until the dummy file is found... Then continue with the data processing ... deleting the dummy file at the end so process is ready to again next time...
LVL 65

Accepted Solution

rockiroads earned 1200 total points
ID: 24243540
use shellwait to do this. An example can be found here http://www.mvps.org/access/api/api0004.htm
You are shelling but it waits for process to complete

LVL 38

Assisted Solution

by:Jim P.
Jim P. earned 600 total points
ID: 24244258
I found this somewhere in the depths of time -- very similar to what rocki linked to.

' Enter the following Declare statement on one, single line before
' anything else in the module:
Declare Function FindWindow Lib user323 Alias FindWindowA (ByVal lpClassName As Any, ByVal lpWindowName As String) As Long
'Then in your function do 
Whil FindWindow(vbNullString, "DOS FTP") <> 0 

Open in new window

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Author Comment

ID: 24248106
Hi Jimpen,

thanks for your input. My system does not find Lib "user323".


Author Comment

ID: 24248165
Hi therealmongoose,

thanks for this idea. Unfortunately for this specif problem it doesn'T work (cannot writ any flie onto ftp server).

Author Comment

ID: 24248174
Hi Jimpen,
I checked with "user32" it works now. It does not fit perfectly into my scenario.
Thanks anyway,


Author Closing Comment

ID: 31575026
All 3 works and I may be able to use them in different scenarios.
This hint wit  http://www.mvps.org/access/api/api0004.htm meets my requirements for this specific case best.
Thanks guys for your help.
LVL 38

Expert Comment

by:Jim P.
ID: 24250133
Glad to be of assistance. May all your days get brighter and brighter.

Featured Post

Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Suggested Courses

868 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