torekp Posted June 24, 2011 Report Share Posted June 24, 2011 (edited) Here's a trick I've used to tell which computer my Labview exe is running on: 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 ) 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 June 24, 2011 by torekp Quote Link to comment
John Lokanis Posted June 24, 2011 Report Share Posted June 24, 2011 Or, you could do something like this (if you are using Windows OS): If you need the IP address, get the AddressList from the IPHostEntry, index the first element and use ToString to convert it to an IP string. Quote Link to comment
Jordan Kuehn Posted June 24, 2011 Report Share Posted June 24, 2011 (edited) 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. 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 June 24, 2011 by jkuehn Quote Link to comment
torekp Posted June 28, 2011 Author Report Share Posted June 28, 2011 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? Quote Link to comment
Jordan Kuehn Posted June 28, 2011 Report Share Posted June 28, 2011 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. 1 Quote Link to comment
torekp Posted June 28, 2011 Author Report Share Posted June 28, 2011 (edited) 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. Thanks again. Edited June 28, 2011 by torekp Quote Link to comment
Jordan Kuehn Posted June 28, 2011 Report Share Posted June 28, 2011 no problem. glad I could help! Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.