Results 1 to 8 of 8

Thread: Dos Commands

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2000
    Location
    Manchester NH
    Posts
    833
    How do I run a dos command like

    NSLOOKUP

    within a VB program and have the program retrieve the output

    for example I want to get the IP address of my computer on win NT so I run the dos command

    IPCONFIG
    Kurt Simons
    [I know I'm a hack but my clients don't!]

  2. #2
    Addicted Member
    Join Date
    Jul 2000
    Location
    Scotland
    Posts
    184
    I can send you a module that finds the IP using an API. Email me if you want it.

    This is a big module (100 lines) I'm not sure it its appropriate to post it. Can anybody advise?

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2000
    Location
    Manchester NH
    Posts
    833
    Thanks,

    but there are dozens of dos commands that i use frequently. I was looking for a quick way to get there info automatically

    THIS IS JUST MY IDEA NOT VB CODE
    text1.text = DosShell("192.168.0.1",TimeOutValue)

    etc
    Kurt Simons
    [I know I'm a hack but my clients don't!]

  4. #4
    Junior Member
    Join Date
    Feb 2000
    Posts
    27
    The way i usually do it is to shell the command and append > somefile.txt to the end of the command line. You can then open the text file you created and pull out the data.
    cmd = "cmd /c dir > " & app.path & "\dosresult.txt"


  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2000
    Location
    Manchester NH
    Posts
    833
    I got it to work at the command prompt but
    I couldn't get it to work in VB

    shell ping 127.0.0.1 > c:\test.txt

    correct?
    Kurt Simons
    [I know I'm a hack but my clients don't!]

  6. #6
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    292
    You have to enclose the command in quotes.
    "People who think they know everything are a great annoyance to those of us who do."

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2000
    Location
    Manchester NH
    Posts
    833
    this is my exact vb code


    Private Sub Command1_Click()
    Dim cmd As String

    cmd = "ping 127.0.0.1 > c:\index1.txt"
    Shell cmd,vbMaximizedFocus

    ' max just so I can see what happens



    End Sub


    but it won't work
    Kurt Simons
    [I know I'm a hack but my clients don't!]

  8. #8
    Lively Member
    Join Date
    May 1999
    Location
    Singapore
    Posts
    116
    shell onli excute exes.....
    so if you want to ping, you can try [windows folder]\ping.exe instead
    YC Sim
    Teenage Programmer
    UIN 37903254



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