Results 1 to 7 of 7

Thread: Network Card Enable\Disable

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2002
    Location
    UK
    Posts
    147

    Network Card Enable\Disable

    As part of my program I need to be able to enable/disable the network cards of the computer. I understand that if I use DHCP enabled network cards I can control them using WMI. But unfortunately I need to use static IP addresses, which renders this method redundant.
    Through searching the web I have found this app which does exactly what I want, unfortunately it is in C# and I have very little experience of this language. Could anyone convert this into a VB6 app or give me examples of how to do this in VB6
    Attached Files Attached Files
    Mik706

  2. #2
    Fanatic Member robbedaya's Avatar
    Join Date
    Jul 2002
    Location
    Belgium
    Posts
    872

    Re: Network Card Enable\Disable

    WMI controls hardware-settings. I think WMI should also work when DHCP is enabled (could be wrong though):
    - Because using WMI you can change the mode of an Network card from DHCP to Static.
    - DHCP-mode has nothing to do with enableing/disableing the networc card.
    - Use the thread tools to Mark your Thread as Resolved when your question is answered.
    - Please Rate my answers if they where helpful.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2002
    Location
    UK
    Posts
    147

    Re: Network Card Enable\Disable

    Do you have any examples of how to use WMI to achive this? or even an example of the usage of WMI in any application
    Mik706

  4. #4
    Fanatic Member robbedaya's Avatar
    Join Date
    Jul 2002
    Location
    Belgium
    Posts
    872

    Re: Network Card Enable\Disable

    I do not have a sample but this msdn page should help you:
    http://msdn2.microsoft.com/en-us/library/aa394595.aspx
    - Use the thread tools to Mark your Thread as Resolved when your question is answered.
    - Please Rate my answers if they where helpful.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 2002
    Location
    UK
    Posts
    147

    Re: Network Card Enable\Disable

    Cheers for that link but having read the first paragraph I don’t think that using WMI will work

    If you are using DHCP, you can use the Win32_NetworkAdapterConfiguration and the ReleaseDHCPLease method to release the IP address. If you are not using DHCP, you cannot use WMI to disable a network connection. To re-enable the network connection, use objNetCard.RenewDHCPLease. You can also release or renew all DHCP leases using the ReleaseDHCPLeaseAll and RenewDHCPLeaseAll methods.
    Any suggestions?
    Mik706

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jul 2002
    Location
    UK
    Posts
    147

    Re: Network Card Enable\Disable

    Ignore that last one I have just read the next paragraph:

    Use the Win32_NetworkAdapter class and the Disable or Enable methods.
    Mik706

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jul 2002
    Location
    UK
    Posts
    147

    Angry Re: Network Card Enable\Disable

    I have done some more reading and it would apear that the Enable and Disable functions are only avaiable in Vista!

    So any other ideas would be greatly appreciated.
    Mik706

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width