03-21-2015 09:35 AM
Anyone know how to programatically enable or disable a network adapter in LV?
03-21-2015 12:09 PM
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.
03-22-2015 01:25 AM
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
03-23-2015 04:54 AM
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).
03-23-2015 07:24 AM
Cool -- I didn't know that.
BS