11-05-2014 03:36 PM - edited 11-05-2014 03:39 PM
I need to change my PXI systems IP address dynamically using a LabVIEW VI. Would someone guide me how to do that, an example code would be appreciated 🙂
PXI system's operating system: Windows 7
LabVIEW version: LabVIEW 2014
11-05-2014 03:49 PM - edited 11-05-2014 03:51 PM
Use the System Exec.vi and pass the command netsh interface ipv4 set address “local area connection” static 192.168.1.2 255.255.255.0 192.168.1.254
Change as required for your IP address and subnet.
This is setting an 192.168.1.2 with subnet of 255.255.255.0 and gateway of 192.168.1.254.
11-11-2014 10:25 AM - edited 11-11-2014 10:27 AM
Thanks for the reply!
I have tried this but didn't work for me L
I have attached the vi I tried, let me know something else to be added to this.
11-11-2014 05:05 PM
Well, your command string says "Local Area Connection", but the picture says "Local Area Connection 2". Could that be the problem?
When you say "Change IP address settings dynamically", do you mean change the settings on your PC, or do you mean "find the IP of that device over there" (such as a PXI controller)?
11-14-2014 04:07 PM
Hi Bob, Thank you for the reply!
While highlighting i just highlighted "Local Area Connection 2". Any ways I tried with both "Local Area Connection" and "Local Area Connection 2", it didn't work for me.
When I say "Change IP address settings dynamically", I mean change the settings on the PC(where I run the VI).
11-14-2014 04:51 PM
Hmm -- changing your IP "out from under you" might be a bit tricky. I did a little experiment -- I opened a Command prompt and tried to change the IP of the interface associated with my PXI (I didn't want to mess with the one to the internet!). The following sometimes, but not always, worked for me:
netsh interface ipv4 set address "PXI Network" static 10.0.0.108 255.255.255
You might notice I didn't set a Gateway (not needed, as this is not being routed anywhere). It did seem to make the change, but I sometimes had to dive into Windows' Network setting to see it.
I haven't tried to do this programmatically, but what one does with System Exec is essentially what one does at the Command prompt -- if one works, the other should, too.
So my suggestion would be to open a Command prompt, type in a string like I typed (put your own Interface Name and the IP you want to use), and see if it works. If it doesn't, I suppose it could be a "permissions" thing -- you might get an error message that sheds some light.