PDA

View Full Version : Is this a stupid question (All)



dineshcooper
02-15-2004, 04:49 AM
Hi

All I want to know is if its possible to get a list of all computer's names that are active on a network using wsh and vbscript.

Basically I want to have a list of all computers and all printers in the network so that I can map any printer to any computer. I can already do everything else but i just cant find a way to get all the computer names.
any help will be greatly appreciated. Thanks

dineshcooper
02-22-2004, 03:17 AM
Okay, i found out how to do this. posting here in case anyone else was also wondering.

Dim GlobalName
Dim MyDomain
Dim oDomain
Dim strDomainName
Dim oComputer
Dim count
count = 0
Set GlobalName = GetObject("WinNT:")

For Each MyDomain in GlobalName

Wscript.Echo MyDomain.Name
Set oDomain = GetObject("WinNT://" & MyDomain.Name)
oDomain.Filter = Array("Computer")

For Each oComputer in oDomain
'** Displays each machine in the domain **
Wscript.Echo oComputer.Name
'Set objWMIService = GetObject("winmgmts:\\" & oComputer.Name & "\root\cimv2")
'Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
'Wscript.Echo "UserName: " & objItem.UserName
count = count + 1
Next
Wscript.Echo Count
Next