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. 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.


Simon


--


---------------------------------------------------------------------
"Are you still wasting your time with spam?...
There is a solution!"

Protected by GIANT Company's Spam Inspector
The most powerful anti-spam software available.
http://mail.spaminspector.com

Re: Retrieving the computer name by Torgeir

Torgeir
Tue Dec 02 05:25:02 CST 2003

Michelle Hillard wrote:

> 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. 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?

Hi

This might work (but I'm not sure):

Set oWshNet = CreateObject("WScript.Network")
sComputer = oWshNet.ComputerName


A registry read will always work:

Set oShell = CreateObject("WScript.Shell")

sRegPath = "HKLM\SYSTEM\CurrentControlSet\Control\" _
& "ComputerName\ComputerName\ComputerName"

sCompName = oShell.RegRead(sRegPath)

WScript.Echo sCompName


--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter