string - VB.net Looped ReadLine stops after one line -


ok have run issue trying loop have variable contains list of servers , when try loop loops once , stops

i have part of code below try , give idea i'm doing although have removed data point company work for.

first part of code, gets list of servers domain

dim ostartinfo new processstartinfo("c:\windows\system32\dsquery.exe", "computer " & cnameodd & oservpath & " -o rdn")         ostartinfo.useshellexecute = false         ostartinfo.redirectstandardoutput = true         ostartinfo.redirectstandarderror = true         ostartinfo.createnowindow = true         oprocess.startinfo = ostartinfo         oprocess.start()         using ostreamreader system.io.streamreader = oprocess.standardoutput             soutput = ostreamreader.readtoend() 

output of soutput looks (shown in code below via debug.write("servers: " & soutput)

"serverxafe01" "serverxafe02" "serverxafe03" "serverxafe04" "serverxafe05" "serverxafe06" 

then trying output loop command each server

if soutput = ""                     debug.write("no servers found")                 else                     debug.write("servers: " & soutput)                     dim reader new stringreader(soutput.replace(chr(34), ""))                     while true                         dim line = reader.readline()                         debug.write("line is" & line)                         if line isnot nothing                             dim command string = " user " & user & " /server:" & line                             dim pstartinfo new processstartinfo("c:\windows\sysnative\query.exe", command)                             pstartinfo.useshellexecute = false                             pstartinfo.redirectstandardoutput = true                             pstartinfo.redirectstandarderror = true                             pstartinfo.createnowindow = true                             pprocess.startinfo = pstartinfo                             pprocess.start()                             using pstreamreader system.io.streamreader = pprocess.standarderror                                 soutput = pstreamreader.readtoend()                                 debug.write(soutput & "error " & command)                             end using                             using pstreamreader system.io.streamreader = pprocess.standardoutput                                 soutput = pstreamreader.readtoend()                                 debug.write(soutput & "output" & command)                                 return soutput                             end using                         end if                     end while                 end if             end using 

in code have trying output line processing doing debug.write, anytime run see first line of soutput being used , no other lines being looped, output of debug.write("line :" & line) is

line : serverxafe01 

so never looped through other servers>

i write code try , make work little more productive don't consider myself programmer frustrated , taking calls while concentration on code makes little edgy

so ideas welcome, thank you.

try replace

    while true     '     '     '     '     '     end while 

with

        '     '     '     '     '     loop while line <> "" 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -