Results 1 to 19 of 19

Thread: [02/03] Changing Machine IP address's

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    51

    [02/03] Changing Machine IP address's

    Background Hi here is my problem. Im a system admin and we have just completed a scheme of giving new pc's to disadvantaged children throughout our town. Now we have over 200 machines gone out but they have not been configured with a static IP address so they can access the Internet.

    My Aim
    Ok so what i want to do is create a program in VB.net to send a bispoke version out to each house to change the machines IP address, Subnet, Default gateway and Proxy server + port

    I have found a example here
    HTML Code:
    http://www.dotnetjunkies.com/Article/2BDAC1D8-B277-4A82-B3E7-5B23B910D2B4.dcik
    but it requires a registry key of something like {597C3BDC-2773-4426-A934-8D8CF49C8F7C}
    but i wont have 200 of these keys so thats not really and option unless they are generic as all of the machines have the same network card.


    Does anyone have any ideas

  2. #2
    Fanatic Member Lerroy_Jenkins's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    661

    Re: [02/03] Changing Machine IP address's

    Wouldn't it be easier to create a small help file? Telling them exactly what to do?

    A step by step guide.
    Lerroy

    "η β π", or "Eta Beta Pi" (Eat A Better Pie)

    01001000
    01000101
    01001100
    01010000


    My Own Code - WordCounter

    Useful Forum Links -Reputation - What is it?

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    51

    Re: [02/03] Changing Machine IP address's

    Possiby but i think we would get alot of phonecalls, plus this is what my boss has asked for

  4. #4
    Fanatic Member Lerroy_Jenkins's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    661

    Re: [02/03] Changing Machine IP address's

    Well... I don't know enough about the RegEdit for IP add etc.

    One very sloppy route, that I would recomend using as a last resort is to create a program that basically the user presses a button, and does everything, It opens My network places, it right clicks on this goes to properties, it changes to IP settings and inputs the data itself.

    This can be done via Sendkeys.sendkey () (Which I am looking into at the moment for myself). So each time it gets to a new step it sends a different key to the computer.

    But as I said before, this is very sloopy and a very big cut through a corner idea.
    Lerroy

    "η β π", or "Eta Beta Pi" (Eat A Better Pie)

    01001000
    01000101
    01001100
    01010000


    My Own Code - WordCounter

    Useful Forum Links -Reputation - What is it?

  5. #5

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    51

    Re: [02/03] Changing Machine IP address's

    I have found some information on the following netsh
    So i can do the change to a static IP through dos using this command

    netsh interface ip set address "Local Area Connection 4" static192.168.0.1 255.255.255.0 192.168.0.1 1

    But when i put that into vb.net using the shell command like below

    Code:
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            shell ("netsh interface ip set address "Local Area Connection 4" static 10.81.112.3.0.10 255.255.255.0 192.168.0.1 1")
        End Sub
    I get an error with the Local and im not to sure if the double quotes around the words "local area connetion 4" are causing a problem as the command box apears but nothing else withit.

  6. #6
    Fanatic Member Lerroy_Jenkins's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    661

    Re: [02/03] Changing Machine IP address's

    Inside your code, you have 3 ". Surely you need 4?
    Lerroy

    "η β π", or "Eta Beta Pi" (Eat A Better Pie)

    01001000
    01000101
    01001100
    01010000


    My Own Code - WordCounter

    Useful Forum Links -Reputation - What is it?

  7. #7

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    51

    Re: [02/03] Changing Machine IP address's

    ok now i get no errors with this
    Code:
     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            Shell("netsh interface ip set address" & "Local Area Connection 4" & "static 10.81.112.3.0.10 255.255.255.0 192.168.0.1 1")
        End Sub
    but it still doesnt work

  8. #8
    Fanatic Member Lerroy_Jenkins's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    661

    Re: [02/03] Changing Machine IP address's

    What happens if you try

    vb Code:
    1. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    2.         Shell("netsh interface ip set address Local Area Connection 4 static 10.81.112.3.0.10 255.255.255.0 192.168.0.1 1")
    3.     End Sub
    Lerroy

    "η β π", or "Eta Beta Pi" (Eat A Better Pie)

    01001000
    01000101
    01001100
    01010000


    My Own Code - WordCounter

    Useful Forum Links -Reputation - What is it?

  9. #9

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    51

    Re: [02/03] Changing Machine IP address's

    Does not change the IP
    It needs the double quotes around the Local Area Connection 4

  10. #10

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    51

    Re: [02/03] Changing Machine IP address's

    I have found the ControlChars.Quote but im not to sure how to use it in a long string like this

  11. #11
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: [02/03] Changing Machine IP address's

    If you have just one LAN connection you can use something like this

    netsh interface ip set address local static 10.0.0.9 255.0.0.0 10.0.0.1 1

    Notice the use of local instead of "Local Area Connection x".



    Code:
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            Shell("netsh interface ip set address local static 192.168.0.1 255.255.255.0 192.168.0.1 1")
        End Sub
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  12. #12

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    51

    Re: [02/03] Changing Machine IP address's

    Thanks for your replay both of you i think i have sussed ths part with this code
    Code:
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            Shell("netsh interface ip set address ""Local Area Connection 4"" static 192.168.2.2 255.255.255.0 192.168.2.1 1")
        End Sub
    I was over complicating things with the code i was using before. Now i need to change the proxy server address in internet explorer 7.. Any ideas

  13. #13
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: [02/03] Changing Machine IP address's

    C:\>proxycfg /?
    Microsoft (R) WinHTTP Default Proxy Configuration Tool
    Copyright (c) Microsoft Corporation. All rights reserved.

    usage:

    proxycfg -? : to view help information

    proxycfg : to view current WinHTTP proxy settings

    proxycfg [-d] [-p <server-name> [<bypass-list>]]

    -d : set direct access
    -p : set proxy server(s), and optional bypass list

    proxycfg -u : import proxy settings from current user's
    Microsoft Internet Explorer manual settings (in HKCU)


    I have not used it, so read up on it before you try it. I think there is another option -i, and you may need to restart for changes to take affect.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  14. #14

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    51

    Re: [02/03] Changing Machine IP address's

    Iv just checked and that command doesnt seem to work on vista.. the machines are running vista

  15. #15
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: [02/03] Changing Machine IP address's

    I think it's better to create a .bat file instead of an vb.net exe. Using a batch file, you don't have to worry whether the correct .net framework has been installed on a computer or not.

    PS: for setting proxy via command line in Vista, read this article:
    http://blogs.msdn.com/wndp/archive/2...ows-vista.aspx
    Last edited by stanav; Apr 24th, 2008 at 08:17 AM.

  16. #16

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    51

    Re: [02/03] Changing Machine IP address's

    I dont need to worry due to the fact all of the machines are exactly the same. All 250+ are vista home basic.

    I found the command for adding the proxy on vista
    its done using the netsh command again which is different from xp...

    so if anyone in the future is looking @ this thread look at cmd.exe netsh /?

    Thanks everyone... Also juust a note the proxy change needs a restart to work,.

  17. #17
    Member
    Join Date
    Jun 2003
    Location
    Karachi
    Posts
    58

    Re: [02/03] Changing Machine IP address's

    I am trying to add an arp entry in vista but I am failed.
    I am trying follwing command

    Shell ("netsh interface ipv4 set neighbors ""lan"" ""10.0.0.200"" ""00-10-54-CA-E1-40""")

    Any help from you guys.
    Last edited by azfar; Dec 12th, 2008 at 01:38 PM.

  18. #18
    New Member
    Join Date
    Nov 2008
    Posts
    2

    Re: [02/03] Changing Machine IP address's

    Another possible approach is to use an undocumented Win32 call

    From old VB6 code:
    Public Declare Function SetAdapterIPAddress Lib "iphlpapi" Alias "#135" (ByVal szAdapterGUID As String, ByVal dwDHCP As Long, ByVal dwIP As Long, ByVal dwMask As Long, ByVal dwGateway As Long) As Long

    If interested, I could dig out some associated code.

  19. #19
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: [02/03] Changing Machine IP address's

    ms-dos arp static entry

    arp -s 192.168.1.1 00-aa-00-62-c6-09
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

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