TechSupp Posted October 14, 2012 Posted October 14, 2012 The heads laptop via the wifi needs to have a dhcp setting and no proxy settings at home but at school he needs it to have it with a fixed IP and a proxy setting. Is there a simple utility that I could use to allow this, i.e. a simple click here for home settings etc. Its running W7 if thats any help and could do with the settings taking effect imediately rather than after a reboot.
Steve21 Posted October 14, 2012 Posted October 14, 2012 If you want cheap/simple, why not just make a bat/vbs file that does it? Or did you want something shinier? Steve
TechSupp Posted October 14, 2012 Author Posted October 14, 2012 Its for the head...so its got to be simple!
Steve21 Posted October 14, 2012 Posted October 14, 2012 Not actually tested it but this kind of thing should work: Const HKEY_CURRENT_USER = &H80000001 intmsg = msgbox("Proxy Settings:" & chr(13) & "Are you currently at home?",vbYesNo+vbQuestion,"Location") if intmsg = vbyes then dwvalue = 0 else dwvalue = 1 strComputer = "." Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv") strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings" strValueName = "ProxyEnable" objRegistry.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, strValueName, dwValue Set WSHShell = Createobject("Wscript.Shell") if dwvalue = 0 then WSHShell.Run "netsh interface ipv4 set address name=”Local Area Connection” source=static address=192.168.1.999 mask=255.255.255.0 gateway=192.168.1.1" else WSHShell.Run "netsh interface ipv4 set address name=”Local Area Connection” source=dhcp" end if Will ask if at home, If click yes it'll disable proxy + set static IP. If not at home, will enable proxy (whatever is already set), and set DHCP. Will require open/close of IE (so needs to be done before launching really), but won't require reboot. If you want it done seamlessly even with IE open, need to use something like C# really. That any use? Steve 1
TechSupp Posted October 14, 2012 Author Posted October 14, 2012 Thanks will give that a try, will need the dhcp and static the other way around i.e. static at school, dhcp at home, but may be able to figure how to change that in the script.
CyberNerd Posted October 14, 2012 Posted October 14, 2012 ??? Use a static IP issued by the DHCP server, then set the proxy to autoconfig and use web proxy autoconfig protocol.
Steve21 Posted October 14, 2012 Posted October 14, 2012 Thanks will give that a try, will need the dhcp and static the other way around i.e. static at school, dhcp at home, but may be able to figure how to change that in the script. Gimme a shout if you get any problems, only tested it with msgboxes are didn't want to start messing with my IPs lol. But the logic should work anyway. If you're running anything "fancier" e.g. mozilla might need different reg settings too. Steve
TechSupp Posted October 14, 2012 Author Posted October 14, 2012 Just noticed you got it to chage the LAN connection, it needs to be the WIFI connection, problems with that and where would the dns settings be set for the static at school.
Steve21 Posted October 14, 2012 Posted October 14, 2012 (edited) Just noticed you got it to chage the LAN connection, it needs to be the WIFI connection, problems with that and where would the dns settings be set for the static at school. Depends what your interface name is called. DNS would be as such: netsh interface ip set dns “Local Area Connection” static 192.168.1.1 netsh interface ip set dns “Local Area Connection” dhcp So just add the extra lines wherever you want them. e.g. if dwvalue = 0 then WSHShell.Run "netsh interface ipv4 set address name=”Local Area Connection” source=static address=192.168.1.999 mask=255.255.255.0 gateway=192.168.1.1" WSHShell.Run "netsh interface ip set dns “Local Area Connection” static 192.168.1.1" The names are whatever shows up in CMD e.g. On my pc I have: Ethernet adapter Local Area Connection: Ethernet adapter VirtualBox Host-Only Network: Tunnel adapter Local Area Connection* 12: You'd have a wireless named one (Edit - Also findable in network connections in control panel etc) Steve Edited October 14, 2012 by Steve21
Arthur Posted October 14, 2012 Posted October 14, 2012 Use a static IP issued by the DHCP server, then set the proxy to autoconfig and use web proxy autoconfig protocol. +1. CyberNerd's suggestion makes more sense and should be fool-proof.
3s-gtech Posted October 14, 2012 Posted October 14, 2012 ^^What they said. Just set a reservation in DHCP for that laptop to always get the same address. Then it'll just work, on or off the school network.
mrwobbly Posted October 14, 2012 Posted October 14, 2012 I would imagine it's for a head at a small primary with no server. Download this http://www.dhcpserver.de You can install this DHCP server on any desktop as it has little overhead. Set the IP range for distribution as small or as large as you like. Run it as a service. You will see where when you install as it's simple to setup. The main admin machine is good as it's normally always on. That just leaves you having to put on a proxy toggle. I have a nice graphical one if you want it pm me.
TechSupp Posted October 14, 2012 Author Posted October 14, 2012 Cant do that as I'm really only allowed to do minor things to the admin network or PC's as I only really look after curriculum, anything else is done by the LA. Think I will look at the script, seems simple enough. Should be done by the LA really but they just look after admin and if it involves curriculum or anything out of the ordinary its a no go as far as they are concerned.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now