Results 1 to 6 of 6

Thread: executing a shell function from a vb app.

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    5

    Unhappy

    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.

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    /

    you can't shell a txt file you can only display it..
    you need to shell the bat file

    shell "C:\myfile.bat"
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    5
    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.


  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    ..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\*.*
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  5. #5

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    5
    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.


  6. #6
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    ...

    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

    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width