Results 1 to 3 of 3

Thread: Running Dos commands from VB

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    12

    Post

    It seems as if this should be easy but I'm having no luck so far...

    My company has a number of dos-based utilities which I would like to invoke in a VB(6) program, then redirect the output to a text file. I keep getting 'file not found' even though I have the correct path. To make sure our utilites weren't causing the problem, I tried the following lines, which also resulted in a 'file not found' error:

    DosLine = "dir > d:\vbtest.tmp"
    Holder = Shell(DosLine, vbMaximizedFocus)

    It doesn't matter if vbtest.tmp already exists or not. Does anyone know a way to resolve this problem?

    Ken Franklin
    [email protected]


  2. #2
    Member
    Join Date
    Jun 1999
    Posts
    52

    Post

    Ken-
    I've been looking into the same problem. I'm assuming that the redirection is giving you the problem. The solution that I came up with is to create or write to a batch file. They understand the redirection. So for example you could do this:
    Code:
    Dim sCmds As String
    sCmds = "dir > d:\vbtest.tmp"  
    Open "c:\Dosline.bat" for Output as #1
    Print#1,sCmds
    Close#1
    Then use the Shell() function to execute the .bat file
    -Adam
    Yahoo!: _eclipsed_
    ICQ:18534929

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    12

    Post

    That worked (Thanks, this project has been bugging me) but seems pretty clumsy.

    Does anyone know more about why redirecting doesn't work at a Dos prompt without writing a batch file? Is there a better way to get results from Dos prompts?

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