Solved

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

Posted on 2003-12-02
3
3,002 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

809 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