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
Printable View
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
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?
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
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"
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?
You have to enclose the command in quotes.
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
shell onli excute exes.....
so if you want to ping, you can try [windows folder]\ping.exe instead