LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

enable and disable ethernet adapters

Anyone know how to programatically enable or disable a network adapter in LV?

PaulG.

LabVIEW versions 5.0 - 2020

“All programmers are optimists”
― Frederick P. Brooks Jr.
0 Kudos
Message 1 of 5
(4,044 Views)

The same way you would from any other language - by looking which APIs the OS has for this.

 

If memory serves, this was always a tricky thing (I never ended up actually doing it, but I did look a few times), requiring either going through something called WMI (which I believe has some problematic C structures and callbacks) or by using an external program called DevCon. At least, that's what I get from searching for "network adapter .net" and looking through the results for about a minute. It's possible that there are other options or that this is not as hard as I remember.


___________________
Try to take over the world!
0 Kudos
Message 2 of 5
(4,021 Views)

I believe you might also be able to do this using the "netsh" command (which has a lot of options).  The Good News is that if you can figure out the right options, which probably also involves knowing the "name" that Windows gives your NIC (and you may have more than one ...), you can create a SystemExec call in LabVIEW that should do it.  The Bad News is that this will (probably) have to "run as Administrator", and I have no idea how to get LabVIEW to do that trick.

 

Bob Schor

0 Kudos
Message 3 of 5
(3,993 Views)

Bob - one way to do it would be to have a headless LabVIEW application run as a service. When you install something as a service it runs as 'SYSTEM' which has administrator privileges. You could write a little LabVIEW service that does your 'things requiring admin rights' and have that communicate with your actual application (e.g. over TCP).


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 4 of 5
(3,960 Views)

Cool -- I didn't know that.

 

BS

0 Kudos
Message 5 of 5
(3,945 Views)