Running a batch file

aziz rasul

Active member
Local time
Today, 23:20
Joined
Jun 26, 2000
Messages
1,935
I have the following batch file D:\Telewest\TextFiles\IN\LO_DATA\DATTXT.BAT

The batch file converts .dat files to .txt file extensions. The .dat files are housed in the same directory as the batch file.

The db is housed under C:\ drive.

Behind a command button I have

Call Shell ("D:\Telewest\TextFiles\IN\LO_DATA\DATTXT.bat"', 1)

The DOS windows opens a split second but it doesn't executes the batch file. Running the batch file on its own works.

Can anyone enlighten me of what I'm doing wrong?
 
It most likely deals with your Working Directory. When you launch the bat file from the command prompt for testing did you change directory to D:\Telewest\TextFiles\IN\LO_DATA\.

If so you will need to change the Working Directory of your DB before executing the command. See the CHDIR function.
 
You have an extra single quote (') in your Call Line at the end of your path / file..

Call Shell ("D:\Telewest\TextFiles\IN\LO_DATA\DATTXT.bat"', 1)


Should be:

Call Shell ("D:\Telewest\TextFiles\IN\LO_DATA\DATTXT.bat", 1)

Kenny
 
OK I got it to work. I had to add the following lines

d:
cd D:\Telewest\TextFiles\IN\LO_DATA
ren *.dat *.txt

Here's the VBA code that I'm dealing with

Call Shell("D:\Telewest\TextFiles\IN\LO_DATA\DATTXT.bat", 1)
strImportDir = "D:\Telewest\TextFiles\IN\LO_DATA\"
strFileExt1 = "*.txt"
strFilename1 = Dir(strImportDir + strFileExt1)
If Len(strFilename1) = 0 Then
MsgBox "There are no files available in your chosen directory.", vbInformation, "Information Message"
End If

If I place a breakpoint after the Call statement, I get the name of the file in strFilename1. However if I don't use any breakpoints, Len(strFilename1) is 0. The reason for this is that it takes time to change the file extensions from .dat to .txt since there about upto 30 .dat files and hence assumes that there are no .txt files. How do I go about resolving this timing issue?
 
Interesting i just had a similar problem getting access to find the data.
Anyway as to timing u need to put in something to make it wait straight after u shell to yr bat file,or the vb code moves on before the results come in

Their r 2 ways i do this.
If yr bat file is a single run..just put in a wait statement like
While dir("c:\done.txt" = ""
Wend
Then on the last line of yr bat file put
copy c:\notdone.txt c:\done.txt
Make a litlle notepad file to move around.
(dont forget to clear the done statement in c:\ or it will never work again)

alternatively if like most of my bat files they run thru many times something like
for x = 1 to 300000000
next x

u will just have to play around with the zeros to get the tining right, but for what i do the above figure is fine
Captnk
 
You don't have to use a BAT file to rename files.

You have the following Functions available to you in Access:

1. Name
2. DIR
3. FileCopy
4. Kill


Also instead of creating loops (Which work faster/slower depending on the processor) look into using the Sleep API and the DoEvents[/] or even the AppActivate function. You will create cleaner code that is easier to Debug later.
 
Last edited:
I have used the functions that you stated. However this was another way of doing the same job quickly. Many Thanks for your input.
 

Users who are viewing this thread

Back
Top Bottom