Solved

VBSCRIPT: Retrieving the computer name of computers that have their NIC disabled or dont have one.

Posted on 2003-12-02
3
3,003 Views
Last Modified: 2010-08-05
Hi guys,
I would like to retrieve the computer name on a whole lot of pcs. The
problem is I cannot use a networking object to retrieve it because some of
the pcs have their network card disabled or dont have one at all. I work in retail as a pos support
guy, and we get info from the stores pcs through dialup.

Is there any way to get the host name or computer name of these machines
without doing a query to a network adapter?

Any help greatly appreciated.

I have tried the following:
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colAdapters = objWMIService.ExecQuery _
    ("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled =
True")
For Each objAdapter in colAdapters
    Wscript.Echo "Host name: " & objAdapter.DNSHostName
Next

This works for a pc which has their network adapter card enabled, but even
if I change it to FALSE, for disabled card, it does not return it.
0
Comment
Question by:Simon336697
3 Comments
 
LVL 28

Expert Comment

by:sybe
ID: 9857159
Set oNetwork = CreateObject("WScript.Network")
sComputerName = oNetwork.ComputerName
0
 
LVL 15

Assisted Solution

by:Raisor
Raisor earned 125 total points
ID: 9857766
Hi,

It seems you have only a small range of time to catch the desired data if store pcs come in only through dialup.

What I was thinking of was, that you could use "WMI Notification Events" to enable a "Resource Monitoring" ... so you wouldn't need to care if they dialup at nighttime or at daytime ... you'd only have to watch your Log from time to time ... or find another way to get informed ...

Here you'll find all information about "Monitoring Resources by Using WMI Event Notifications":
http://www.microsoft.com/technet/treeview/default.asp?url=/technet/scriptcenter/scrguide/sas_wmi_miat.asp


Best regards, Raisor
0
 
LVL 41

Accepted Solution

by:
graye earned 125 total points
ID: 9863383
Wait-a-minute...  There's an obvious flaw in this approach.

The WMI script above *USES THE NETWORK* to connect to remote PC.   Uh... think about it.... those PC's are not on the network (because the NIC is disable or don't even have one) are not gonna be visible to the script.

A convoluted way to consider this is... generate a list of known PCs (by some other means... a paper inventory, for example).  Then compare the list that you get from polling the network.  Compare the list to find out who's missing.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This is an explanation of a simple data model to help parse a JSON feed
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question