Jump to content

Which computer is the VI running on?


Recommended Posts

Here's a trick I've used to tell which computer my Labview exe is running on:

post-4616-0-45250700-1308918347_thumb.pn

Most of the computers at my workplace have two ethernet connections, local and network. All network addresses around here begin with "172" so I use that to distinguish the two.

This works as long as the connection of interest (Local, preferably, since that connection is not so intermittent :wacko:) is maintained. Alternatively - on SOME computers but not all - I've found that using the network address works, even when IP number 0 is fed to the IP to String function. That function knows, on some computers, the computer's name (e.g. "Paulsdesktop") even when fed a 0.

But I'm sure somebody out there has a better way to tell which computer you're running on. What is it?

Edited by torekp
Link to comment

A custom windows environment variable could do the trick. Attached is code that I have used a couple times to see which machine it's on.

J2ifr.png

Keep in mind, LabVIEW will not see a new variable without being restarted.

//Edit

Not good if you're only interested in IP address obviously.

Edited by jkuehn
Link to comment

Thanks guys. I don't really need the IP addresses; that was just the only way I knew how to ID the computer.

John, can I do your trick in LV 8.5? I can't seem to find the "Environment" property.

jkuehn, How do I tell Windows to set a custom environment variable? Is there a Windows system file that I edit?

Link to comment

jkuehn, How do I tell Windows to set a custom environment variable? Is there a Windows system file that I edit?

It varies a bit from OS to OS, but it's something along the lines of this (Windows 7). Right click Computer -> Properties -> Advanced System Settings -> Advanced Tab -> Environment Variables...

Then you are presented with user variables and system variables that you can modify all you want.

  • Like 1
Link to comment

something along the lines of this (Windows 7). Right click Computer -> Properties -> Advanced System Settings -> Advanced Tab -> Environment Variables...

Yup, thanks. Basically the same on XP. Instead of defining a custom variable, though, I just put

cmd /c echo %ComputerName%

in the string, and otherwise identical to your block diagram. :thumbup1: Thanks again.

Edited by torekp
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.