|
-
Apr 24th, 2008, 03:09 AM
#1
Thread Starter
Member
[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
-
Apr 24th, 2008, 03:18 AM
#2
Fanatic Member
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.
-
Apr 24th, 2008, 03:20 AM
#3
Thread Starter
Member
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
-
Apr 24th, 2008, 03:30 AM
#4
Fanatic Member
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.
-
Apr 24th, 2008, 03:53 AM
#5
Thread Starter
Member
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.
-
Apr 24th, 2008, 03:56 AM
#6
Fanatic Member
Re: [02/03] Changing Machine IP address's
Inside your code, you have 3 ". Surely you need 4?
-
Apr 24th, 2008, 03:58 AM
#7
Thread Starter
Member
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
-
Apr 24th, 2008, 04:01 AM
#8
Fanatic Member
Re: [02/03] Changing Machine IP address's
What happens if you try
vb 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
-
Apr 24th, 2008, 04:03 AM
#9
Thread Starter
Member
Re: [02/03] Changing Machine IP address's
Does not change the IP
It needs the double quotes around the Local Area Connection 4
-
Apr 24th, 2008, 04:20 AM
#10
Thread Starter
Member
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
-
Apr 24th, 2008, 04:58 AM
#11
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
-
Apr 24th, 2008, 06:20 AM
#12
Thread Starter
Member
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
-
Apr 24th, 2008, 06:41 AM
#13
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.
-
Apr 24th, 2008, 07:53 AM
#14
Thread Starter
Member
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
-
Apr 24th, 2008, 08:04 AM
#15
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.
-
Apr 24th, 2008, 10:02 AM
#16
Thread Starter
Member
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,.
-
Dec 12th, 2008, 01:29 PM
#17
Member
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.
-
Jan 9th, 2009, 10:02 AM
#18
New Member
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.
-
Jan 9th, 2009, 11:13 AM
#19
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|