-
I wrote a VB application for creating a .bat file by using the "Open File For Output As" method.
In the created .bat file an ftp function, ftp -s:TRAN.TXT, is called. I tried both Shell "ftp -s:TRAN.TXT" and RetVar = Shell ("c:\TRAN.TXT"), respectively, in the VB application (as the last line of code) but neither worked.
I checked the location of the TRAN.TXT file, which was sitting in c:\, the same path as the created .bat file.
The .bat file was created correctly because if the .bat file was executed manually, the ftp -s:tran.txt functiion would then be called and performed properly.
Thanks for anyone who can help me out.
-
/
you can't shell a txt file you can only display it..
you need to shell the bat file
shell "C:\myfile.bat"
-
THANK YOU SO MUCH FOR THE QUICK RESPONSE.
I FORGOT TO MENTION IN MY QUESTION MESSAGE THAT I TRIED ALSO TO SHELL THE .BAT FILE, BUT IT DID NOT WORK, EITHER.
-
..works for me...
Private Sub Command1_Click()
Shell "c:\cleaner.bat", vbNormalFocus
DoEvents
End Sub
'cleaner.bat (clean history and temp files
DELTREE /Y C:\WINDOWS\HISTORY\*.*
DELTREE /Y C:\WINDOWS\TEMPOR~1\*.*
-
Thanks again for your help. But I still cannot make it work.
For your refernece, the following is the application for creating the .bat file, plus the .txt file to be executed by a ftp command:
------------------------------------------------
Public Sub Main()
Dim BatchFile As String
Dim D
BatchFile = "C:\"
D = Format$(Date, "mmddyy")
Open BatchFile & "TRAN.bat" For Output As #1
Print #1, "ftp -s:TRANS.txt"
Print #1, ""
Print #1, "rename C:\CREDIT Cr" & D
Print #1, "rename C:\JSTORDR Js" & D
Print #1, ""
Print #1, "copy C:\Cr" & "*.*" & " C:\Info\"
Print #1, "copy C:\Js" & "*.*" & " C:\Info\"
Print #1, ""
Print #1, "Del C:\Cr" & D
Print #1, "Del C:\Js" & D
Close #1
Shell "ftp -s:" & "C:\TRAN.BAT"
End Sub
----------------------------------------------------
TRANS.txt
open mycompany
myuser
mypword
cd /tmp
get CREDIT
get JSTORDR
quit
---------------------------------------------------
Thank you.
-
...
Shell "ftp -s:" & "C:\TRAN.BAT"
not sure on this line as I haven't really played with ftp.
did you try to shell the tran.bat file seperately to
see whether you are stuck on the ftp end or the shell?
Your create works fine so if you shell it, it should work...
'this will open and run the tran.bat and close the dos
'window when finished.
Wish I could be of more help but I am lost on ftp
Dim h As Long
h = Shell(Environ("COMSPEC") & " /C C:\Tran.bat")
DoEvents