Re: readLine method help
Kendoh wrote:
Now I have this problem... I am trying to get all computers of a subnet into
a txt file. Here is the code. I am not getting any output... When I use your
code without the if loop, it writes localhost into the document... What am I
doing wrong?
dim fso, fl, count
count = 1
ip = 1
Set fso = CreateObject("Scripting.FileSystemObject")
Set fl = fso.CreateTextFile("C:\\Temp\Test.txt", true)
if count <> 256 Then
Set objShell = CreateObject("WScript.Shell")
Set objWshScriptExec = objShell.Exec("nslookup 158.187.145.&count&")
(snip)
Hi,
You are trying to use nslookup against 158.187.145.&count&.
You will need to put the count variable outside the quoted string.
Change
("nslookup 158.187.145.&count&")
to
("nslookup 158.187.145." & count)
and see if it helps.
I assume you are going to make a loop eventually, so you should also
"reset" the strName variable inside the loop to avoid inheriting
previous value if the 'If Left(strLine, 5) = "Name:" Then' test doesn't
kick in.
So change
Set objStdOut = objWshScriptExec.StdOut
Do Until objStdOut.AtEndOfStream
to
Set objStdOut = objWshScriptExec.StdOut
strName = ""
Do Until objStdOut.AtEndOfStream
--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx
.
Relevant Pages
- Re: How to make Internet Explorer window top most?
... > How to place Internet Explorer on top(modal window). ... You could set a title, and use AppActivate on it, an example here: ... You should add an "WScript.Sleep 100 in this loop to avoid CPU hogging. ... -- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: ... (microsoft.public.windows.server.scripting) - Re: Sleep until any keystroke
... SAPIEN Technologies - Scripting, Simplified.www.SAPIEN.com ... VBScript & Windows PowerShell Training -www.ScriptingTraining.com/classes.asp ... Within the loop, insert the Do While stdin example. ... I think by design that ReadLine for STDIN will sit and wait forever. ... (microsoft.public.scripting.vbscript) - Re: Copy and rename folder
... > Instead of renaming it to mmddyyfolder, rename it to Mainfolder_yyyymmdd. ... > ' Dim FSO As Scripting.FileSystemObject ... > If I set a reference to microsoft scripting runtime, ... >> macro that will make a copy and rename it. ... (microsoft.public.excel.misc) - Re: readLine method help
... Is there a way to make the cmd execution window not ... >> code without the if loop, it writes localhost into the document... ... > Set objStdOut = objWshScriptExec.StdOut ... > torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway ... (microsoft.public.scripting.vbscript) - Re: error Name redefined for Const value
... > Is there a better way to declare the variable? ... You can never define a Const inside a loop, ... -- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: ... (microsoft.public.windows.server.scripting) |
|