Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading info from DOS Window

Status
Not open for further replies.

keybrdcowboy

IS-IT--Management
Aug 31, 2004
96
US
This seems like it should be very simple, but I can't get it to work. I have a text file that contains a list of machine names, and I need to run a command line that does an nslookup and outputs the results to a text file. So far I am just trying to get the output to a file to work. I can do a "nslookup machinename > textfile" and that works fine from the command prompt, but when I run "set Shell = CreateObject("WScript.Shell")
'
'commandline = "%systemroot%\System32\nslookup Lak37cswk13903 > c:\nslookup.txt"
'Shell.Run commandline, 1 , True" I get nothing. Can anyone help? Thanks.
 
Try this:

Dim sh

set sh = createobject("wscript.shell")

sh.run "%comspec% /c nslookup microsoft.com> f:\Data\NSData.txt",0,true
 
Have a look at the Exec method (and the object it returns)of the Shell
 
You may also consider the Exec method and the StdOut property:
Set Shell = CreateObject("WScript.Shell")
Set oExec = Shell.Exec("nslookup Lak37cswk13903")
Do While oExec.Status = 0
WScript.Sleep 100
Loop
WScript.Echo oExec.StdOut.ReadAll

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Can someone point me to some information on the Exec method and StdOut property? I am looking on the DevGuru website, and don't see it listed up there. Thanks for the help. PHV, that seems to work. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top