Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I enable/disable network connection options programmatically

When I open the properties on a network connnection on windows, I see this dialog: Connection_Properties http://www.freeimagehosting.net/uploads/ca7a4d82ea.png

In this dialog, in the check-listbox I can enable or disable options like "File or printer sharing", "client for microsoft networks" or network filter drivers.

My question is: How can I enable/disable these options programatically? I didn't find anything that looks like this in the WMI documentation and I couldn't find any other Win32 API for this. I would prefer a C Win32 API or WMI interface, but a solution using any programming language is welcome. The question is language-agnostic.

like image 785
Niki Avatar asked Oct 15 '22 06:10

Niki


1 Answers

I think INetCfg is what you're looking for:

http://msdn.microsoft.com/en-us/library/ff547694%28VS.85%29.aspx

Edit: Here's a link to a discussion where someone uses INetCfg to disable just File & Printer sharing.

http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/b0407073-07bc-462b-9de9-7295be5fa183

like image 96
Hans Olsson Avatar answered Oct 18 '22 14:10

Hans Olsson