![]() ![]() To install new Microsoft Loopback Adapter use InstallNewVtNic() function. This function is used in the example by every other helper functions like GetVtNicCount(). Name, NetConnectionID, PNPDeviceID, ConfigManagerErrorCode, NetConnectionStatus ManagementObjectSearcher searcher = new ManagementObjectSearcher( String.Format( ![]() ServiceName = "msloop" // Microsoft Loopback Adapter Public static ManagementObjectCollection QueryVirtualNetAdapters() Necessary methods are located in System.Management namespace ( reference needed). WMI access is provided by QueryVirtualNetAdapters() function. P.StartInfo.RedirectStandardError = true UseCommand(CommandType commandType, string command) Check attachment.įunction UseCommand() was created to execute external commands (devcon, netsh, other after some changes) and redirect output to application's console. I have removed comments from code snippets here for better readability. The class code is not optimized but should work on most Windows systems (tested on XP and 7 64bit). MACAddress (returns MAC address if device is connected)Įxample application shows how to make and use of MSLoopbackTool utility class.NetConnectionStatus (for connection info).ConfigManagerErrorCode (for device state info).NetConnectionID (returns connection name).Be aware that many of this class's properties are not available on every Windows version. The full documentation link is here: (VS.85).aspx. It provides some useful properties used in example code to get connection name, instance ID and adapter state information. The WMI class Win32_NetworkAdapter represents an IPv4 network adapter. For XP it is usually faster when used on disabled device (because of DHCP request). Note that for Vista and 7 (64bit) network adapter must be enabled before setting IP. Where 'name' is a NIC's connection name (can be obtained with WMI), '192.168.0.3' is an IP and '255.255.255.0' is a mask.ĭepending on Windows version this command can return "Ok." string if succeed or nothing. Netsh int ip set address name="Local Area Connection 2" static 192.168.0.3 255.255.255.0 (single line command) According to online documentation "Netsh is a command-line scripting utility that allows you to, either locally or remotely, display or modify the network configuration of a computer that is currently running." More information is available here: (WS.10).aspx. To configure static IP address use Netsh command (standard Windows utility). to install Microsoft Loopback Adapter (device is enabled by default after installation)ĭevcon install %WINDIR%\Inf\Netloop.inf *MSLOOPĭevcon enable about install parameter: amd64 version (Vista, 7 64bit) of devcon will enable all other already installed msloop devices even if they were disabled (marked in example code).You can use hardware ID with wildcards (*) or instance ID prefixed with as a commands parameters. Note: for Windows Vista and 7 (64bit) use amd64 version (not ia64).ĭevcon is a handy way to list, disable, enable, install and remove of devices. There are few versions of this tool depending on system architecture. Devcon is a console version of device manager provided by Microsoft in WDK (Windows Driver Kit). You can add it manually using device manager – I wrote about this in my previous entry linked here or through console with devcon tool. Windows systems have their own virtual network adapter called Microsoft Loopback Adapter (msloop). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |