Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Net View command in VB script?

781 views
Skip to first unread message

msnews.microsoft.com

unread,
Apr 2, 2002, 4:39:49 PM4/2/02
to
How can I do the equivilent of a 'net view' type command (shown below) with
vbscript?

Say on the domain all my server names start with the text MYSERVERS (Such as
Myservers01, myservers02, etc.)

from the command line I can do: net view /domain:mydomain |find /i
\\myservers

(This command queries the domain and returns all servers that begin with
'myservers')

Any ideas?
Brian


Gurgen

unread,
Apr 2, 2002, 5:55:24 PM4/2/02
to
Two methods:

1. Using ADSI. (Running on NT or W9x would require ADSI v2.5 loaded.)
--------------------
Set oCont = GetObject("WinNT://" & "Domain_Name")
oCont.Filter = Array("Computer")
For Each server In oCont
    sName = LCase(server.Name)
    If InStr(sName, "myservers") <> 0 Then
            Wscript.Echo sName
    End If
Next
--------------------

2. Execute "net view" within VB Script. ( v5.6 require)

Set shell=Wscript.CreateObject("Wscript.Shell")
Set oExec = shell.Exec ("%comspec% /c net view /domain:quant |find /i ""myservers""")
Do while not oExec.StdOut.AtEndOfStream
     dump = dump & vbcrlf & oExec.StdOut.ReadLine
Loop
Wscript.Echo dump

Regards,
--
Gurgen Alaverdian
http://www.gurgensvbstuff.com
"msnews.microsoft.com" <btu...@hotmail.com> wrote in message news:#8vU66o2BHA.2400@tkmsftngp02...
0 new messages