Reputation: 1
On Windows Server 2008 R2 we have multiple network adapters. We have a legacy program that has to bind with a particular network adapter. It does not always select the correct one. I need to disable the incorrect network adapters, then start the program and then enable the network adapters again. I am having trouble disabling the adapters. Could someone provide a C++ example? The compiler is Embarcadero C++ XE2.
Upvotes: 0
Views: 2824
Reputation: 2251
Thanks to Pablo, this is the c++ command:
HINSTANCE retVal = ShellExecute(NULL, "open", "cmd", "/c netsh interface set interface \"Local Area Connection\" ENABLED", NULL, SW_NORMAL);
Upvotes: -1
Reputation: 9
I think it is not necessary to use c++. Batch file can do it.
The file is as below:
To disable the interface run:
netsh interface set interface “Local Area Connection” DISABLED
To enable the interface run:
netsh interface set interface “Local Area Connection” ENABLED
Upvotes: 0