Change system IP address and DNS setting automatically

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • adeelg39
    New Member
    • Nov 2008
    • 1

    Change system IP address and DNS setting automatically

    Dear friends,
    can any one guide me how to write a code (or show me a snipet of code) in VB6 which can change the IP address and DNS of the computer to my desired addresses. I have 2 networks one in office and one at home both require me to manually change my IP and DNS every time in my laptop.
  • jg007
    Contributor
    • Mar 2008
    • 283

    #2
    connecting to WMI would probably be easiest and I believe that you can set IP address easy enough via that the only issue would be locating the correct network adaptor as it would usually show approx 10 items including the infared port

    the WMI query would probably be ' SELECT * FROM Win32_NetworkAd apterConfigurat ion ' and then run through that till you find the correct adaptor

    sorry, I don't have any code available but if you cannot find anything I will work some out.

    the items available through WMI on the network card -


    instance of Win32_NetworkAd apterConfigurat ion
    {
    Caption = "[00000009] Ralink RT2500 Wireless LAN Card";
    DatabasePath = "%SystemRoot%\\ System32\\drive rs\\etc";
    DefaultIPGatewa y = {"<your default gateway>"};
    Description = "Ralink RT2500 Wireless LAN Card - Virtual Machine Network Services Driver";
    DHCPEnabled = TRUE;
    DHCPLeaseExpire s = "20081109150849 .000000+000";
    DHCPLeaseObtain ed = "20081104150849 .000000+000";
    DHCPServer = "<your DHCP server here>";
    DNSDomain = "<Domain Name>";
    DNSEnabledForWI NSResolution = FALSE;
    DNSHostName = "<your hostname here>";
    DNSServerSearch Order = {"<your DNS addresses here>"};
    DomainDNSRegist rationEnabled = FALSE;
    FullDNSRegistra tionEnabled = TRUE;
    GatewayCostMetr ic = {25};
    Index = 9;
    IPAddress = {"<your IP address here>"};
    IPConnectionMet ric = 25;
    IPEnabled = TRUE;
    IPFilterSecurit yEnabled = FALSE;
    IPSecPermitIPPr otocols = {"0"};
    IPSecPermitTCPP orts = {"0"};
    IPSecPermitUDPP orts = {"0"};
    IPSubnet = {"255.0.0.0" };
    IPXEnabled = FALSE;
    MACAddress = "00:0E:2E:66:37 :02";
    ServiceName = "RT2500";
    SettingID = "{E598F9ED-4410-4D57-AB66-8EF153AA6727}";
    TcpipNetbiosOpt ions = 0;
    WINSEnableLMHos tsLookup = TRUE;
    WINSScopeID = "";
    };

    Comment

    • jg007
      Contributor
      • Mar 2008
      • 283

      #3
      just found this -



      this is VBscript but you should be able to convert it to vb pretty easily

      Comment

      Working...