Please help before I go nuts with the batch file

M

Marco

Hello,
I triyng to run a batch file in order to upload a site.

So with the help of some this newsgroups members I'm already calling the
batch file from shell commands.

what I want, is to press a access button and then upload some files to FTP
server.

the batch file is ok and also the txt file wich contains because if I double
click on the batch file it works.

» This is what I have in the access VBA code:
Shell "C:\site\upload.bat", vbNormalFocus

» This is what I have in the batch file:
ftps.exe -a -s:C:\site\ftp.txt

» This is what I have in the txt file that contains the FTP commands:
open ftp.mysite.com
username
password

cd db

put access.mdb
y


Whay is not working?

regards,
Marco
 
U

UpRider

Marco, try this for your button_click code:

dim MyTask as variant
MyTask = Shell("C:\site\upload.bat", 1)

HTH, UpRider
 
M

Marco

Hi.

It's not working my friend.

It open the batch file, but I don't know what happens because the dos window
opens and closes very fast and I can't read what into.

But it doesn't work.

Any ideas?

I also had to change the path to: C:\pobidos\basedados\callftp.bat it that a
problem?

Regards,
Marco
 
C

Clif McIrvin

Marco said:
Hi.

It's not working my friend.

It open the batch file, but I don't know what happens because the dos
window
opens and closes very fast and I can't read what into.

Marco - try changing your batch file to:

pause
ftps.exe -a -s:C:\site\ftp.txt
pause

this should open the DOS window with a prompt to "Press any key to
continue..." and issue the ftps command after you press a key; then
return to the "Press any key ..." prompt before closing.

This should allow you to see any messages that are getting displayed.

- or -

change your batch file to

ftps.exe -a -s:C:\site\ftp.txt > myftplog.txt 2>&1

This will create the file myftplog.txt in the current folder (whatever
that is) and write any screen output (including error messages) to the
text file.

You can put myftplog.txt anywhere you want it by adding the full path: C
:\some\path\to\myftplog.txt -- or "C:\some long\path
name\to\myftplog.txt" (the quotes are required if there are spaces in
the filename.)

If you want to keep the log file and add to it each time instead of
creating it new each time use

ftps.exe -a -s:C:\site\ftp.txt >> myftplog.txt 2>&1

or, to include a time stamp use:

@echo %date% >> myftplog.txt 2>&1
@echo %time% >> myftplog.txt 2>&1
ftps.exe -a -s:C:\site\ftp.txt >> myftplog.txt 2>&1


the > or >> redirects the normal screen output (to mtftplog.txt), and
the 2>&1 causes any error messages to redirect along with normal output.


HTH

--
Clif
Still learning Access 2003
(but I do know something about DOS Batch commands <grin>)
 
C

Clif McIrvin

(I forgot to say that I'm assuming at least Windows XP for my
redirection and timestamp suggestions.)
 
U

UpRider

Marco, this will work for WinXP, but not Vista. UAC stops it.

Sub subRunBatch()
Dim MyTask As Variant
Dim AppPath As String
Dim strFileToRun As String
strFileToRun = "c:\batchfiles\bgendb.bat"
AppPath = "c:\windows\system32\cmd.exe /k "
'Debug.Print AppPath & " """ & strFileToRun & """"
MyTask = Shell(AppPath & " """ & strFileToRun & """", 1)
End Sub

Change strFileToRun for your batch file.
AppPath is probably OK. If not change it to point to cmd.exe. The /k is
required to keep the window open.
The syntax above is correct and tested. Copy and paste to avoid typing
errors.
Again, if you're using VISTA, it will not work unless you turn off UAC or
figure out how to run cmd.exe elevated.

HTH, UpRider
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top