Does this seem right? (Its kinda hard to test me script since I'm home and its for work...)
code:
"OptionButton3".Onclick = "$x=3
If $Wait.Tag = 1
Goto cmdList()
EndIf
EndFunction
Function cmdList()
$temp = "%temp%\netview.tmp"
$list = "%temp%\list.tmp"
Shell '%comspec% /c net view >"$temp"'
Select
Case $x=1
;--------------------------------
; For all systems
;--------------------------------
If Open(1,"$temp") = 0
$line = ReadLine(1)
While @error=0
If $line AND SubStr($line,1,4) = "\\S0" OR $line AND SubStr($line,1,3) = "\\W" OR $line AND SubStr($line,1,3) = "\\L"
$hostname=SubStr($line,3,InStr($line," ")-1)
Open(2, "$list", 5) = 0
WriteLine(2, $hostname + Chr(13) + Chr(10))
Close(2)
EndIf
$line = ReadLine(1)
Loop
$_ = Close(1)
EndIf
Case $x=2
;-------------------------------------
; if statement for S'
;-------------------------------------
If Open(1,"$temp") = 0
$line = ReadLine(1)
While @error=0
If $line AND SubStr($line,1,4) = "\\S0"
$hostname=SubStr($line,3,InStr($line," ")-1)
Open(2, "$list", 5) = 0
WriteLine(2, $hostname + Chr(13) + Chr(10))
Close(2)
EndIf
$line = ReadLine(1)
Loop
$_ = Close(1)
EndIf
Case $x=3
;-----------------------------------
; if statement for Corporate
;-----------------------------------
If Open(1,"$temp") = 0
$line = ReadLine(1)
While @error=0
If $line AND SubStr($line,1,3) = "\\W" OR $line AND SubStr($line,1,3) = "\\L"
$hostname=SubStr($line,3,InStr($line," ")-1)
?"hostname=" $hostname
Open(2, "$list", 5) = 0
WriteLine(2, $hostname + Chr(13) + Chr(10))
Close(2)
EndIf
$line = ReadLine(1)
Loop
$_ = Close(1)
EndIf
Case $x=4
;---------------------------------
; use the failed list to run the
; inventory against.
;---------------------------------
EndFunction