Set IP Address Programmatically Using LabVIEW

Updated Oct 22, 2023

Reported In

Software

  • LabVIEW

Issue Details

  • Is it possible to set the IP address, Subnet Mask, and Default Gateway of my computer programmatically in LabVIEW?

Solution

You can change network configurations using the System Exec VI, which invokes the command window. Right-click on the Block Diagram of a VI to show the Functions Palette and navigate to Connectivity>>Libraries & Executables and place the System Exec.vi on the block diagram. Right-click on the Command line input terminal of the System Exec.vi and select Create Constant. In the created string constant, type the following arguments:

netsh interface ip set address name="Local Area Connection" static 192.168.0.100 255.255.255.0 192.168.0.1 1

This will configure the connection named Local Area Connection to use static IP address 192.168.0.100, subnet mask 255.255.255.0 and DNS server 192.168.0.1 1.
 

Additional Information

In some cases, running the vi will not work due to Windows security permission. In order to workaround this security issue, Right-click Labview.exe and select Run as Administrator. If errors persist contact your network administrators to confirm no other network misconfigurations may be causing unexpected behaviors.