Thread: Programmatically Changing Network Settings

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    35

    Question Programmatically Changing Network Settings

    Hi,

    I am trying to write a small program that has the ability to change the pc's IP address, Workgroup and DNS settings.

    Can anyone tell me if this is possible, and how to do it, or point me to any resoucres.

    Many Thanks

    Magic

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    What OS?

    gg

  3. #3
    Registered User
    Join Date
    Sep 2004
    Posts
    35
    Windows XP Pro

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981

  5. #5
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    I recently did some work with netsh so can offer these command samples:
    Code:
    /* Sets the DNS servers. */
    netsh interface ip set dns name="Local Area Connection" source=static addr=10.0.0.1
    netsh interface ip add dns name="Local Area Connection" addr=10.0.0.2
    
    /* Sets the IP address. */
    netsh interface ip set address name="Local Area Connection" addr=10.0.0.9 mask=255.255.255.0 gateway=10.0.0.1
    I don't think that netsh can change the workgroup name but you can use the NetJoinDomain function.

    Alternatively, these tasks can be performed using WMI with the Win32_NetworkAdapterConfiguration and Win32_ComputerSystem classes.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sorting the matrix question..
    By transgalactic2 in forum C Programming
    Replies: 47
    Last Post: 12-22-2008, 03:17 PM
  2. Replies: 5
    Last Post: 09-14-2006, 09:47 PM
  3. Programmatically changing IE security settings
    By bennyandthejets in forum Windows Programming
    Replies: 2
    Last Post: 07-07-2004, 01:46 AM
  4. changing drive letter gaining access to a network
    By zornedge in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 11-29-2001, 10:57 AM
  5. Changing drive letter to go on a network
    By zornedge in forum C++ Programming
    Replies: 2
    Last Post: 11-29-2001, 07:30 AM