LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieving Computer Network Name via Labview

Hi Everyone,
We are having difficulties in reading the computer name from some Windows 2K computers.

We are using the standard 'String to IP.vi' (unwired) connected to the 'IP to String.vi' to collect the computer name from the computer. In the most case this works a treat.

Unfortunately for some computers running windows 2K, the vi is not reading back the correct computer name as detailed in the Network Identification tab in the System part of the control Panel.
We believe this is due to an incorrect IP address being picked up.

So, my question is:
Is there another method for obtaining the computer identification string directly from the computer itself without resorting to retrieving the IP address first?

We are running this LV7.0 Application on Windows NT, 2K and XP on a Windows 2K Server.

Thank you in Advance for you help.

Sammy Mason

Software Engineer
e2v technologies
Chelmsford
UK
0 Kudos
Message 1 of 8
(4,193 Views)
As an alternative, you can read the registry. HKEY_LOCAL_MACHINE>SYSTEM>CurrentControlSet>Control>ComputerName has two entries. One is ComputerName and the other is ActiveComputerName. On mine, they're both the same so you'd have to check on yours to see if there's a difference.
Message 2 of 8
(4,185 Views)
Thank you very much for your help and your speedy reply - This now works a treat!

Many Thanks again,

Sammy Mason
0 Kudos
Message 3 of 8
(4,167 Views)
It works just fine here under W2k. Is there anything special for the machines that don't work, e.g. multiple ethernet interfaces?

Just an idea: Try to wire an explicit "127.0.0.1" to the "string to IP" input, see if it makes a difference. (Or just wire a U32 diagram constant of x7F000001 to "IP To String"). This is the genreic "localhost" IP that every device should understand as pointing to itself.
0 Kudos
Message 4 of 8
(4,165 Views)

Sometimes, the user may donot have access to HKEY_LOCAL_MACHINE . In that case, we can use the following command to get the computer's name in the network. 

SET USERDOMAIN

 

 

This command will return: USERDOMAIN=computername

 

0 Kudos
Message 5 of 8
(3,779 Views)

cmd /a set userdomain

0 Kudos
Message 6 of 8
(3,776 Views)

Of course the question is if this will really work in the above special cases where the plain LabVIEW method did not work for some reason. Have you tried?

 

(This is a 6+ year old thread, and many thing have probably changed)

0 Kudos
Message 7 of 8
(3,769 Views)

@karthikeyan90 wrote:

Sometimes, the user may donot have access to HKEY_LOCAL_MACHINE . In that case, we can use the following command to get the computer's name in the network. 

SET USERDOMAIN

 

 

This command will return: USERDOMAIN=computername

 




This does not return the computer name.  It returns the computers DOMAIN.  If the PC is not part of a domain, it will return the PC name, but if part of a domain, this will not return the PC name.  Your mathod should NEVER be used, as it is not guaranteed to work between computers.

 

The best method (in my opinion) is to use the WinAPI function GetComputerName.

 

 

Message 8 of 8
(3,763 Views)