+ Post New Thread
Results 1 to 13 of 13
Wireless Networks Thread, How to switch between DHCP and static settings easily? in Technical; The heads laptop via the wifi needs to have a dhcp setting and no proxy settings at home but at ...
  1. #1
    TechSupp's Avatar
    Join Date
    Mar 2007
    Location
    South Yorkshire
    Posts
    1,830
    Thank Post
    288
    Thanked 112 Times in 93 Posts
    Rep Power
    39

    How to switch between DHCP and static settings easily?

    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.

  2. #2

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,662
    Thank Post
    324
    Thanked 506 Times in 474 Posts
    Rep Power
    177
    If you want cheap/simple, why not just make a bat/vbs file that does it?

    Or did you want something shinier?

    Steve

  3. #3
    TechSupp's Avatar
    Join Date
    Mar 2007
    Location
    South Yorkshire
    Posts
    1,830
    Thank Post
    288
    Thanked 112 Times in 93 Posts
    Rep Power
    39
    Its for the head...so its got to be simple!

  4. #4

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,662
    Thank Post
    324
    Thanked 506 Times in 474 Posts
    Rep Power
    177
    Not actually tested it but this kind of thing should work:

    Code:
    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

  5. Thanks to Steve21 from:

    TechSupp (14th October 2012)

  6. #5
    TechSupp's Avatar
    Join Date
    Mar 2007
    Location
    South Yorkshire
    Posts
    1,830
    Thank Post
    288
    Thanked 112 Times in 93 Posts
    Rep Power
    39
    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.

  7. #6


    Join Date
    Jan 2006
    Posts
    8,202
    Thank Post
    442
    Thanked 1,032 Times in 812 Posts
    Rep Power
    338
    ???

    Use a static IP issued by the DHCP server, then set the proxy to autoconfig and use web proxy autoconfig protocol.

  8. #7

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,662
    Thank Post
    324
    Thanked 506 Times in 474 Posts
    Rep Power
    177
    Quote Originally Posted by TechSupp View Post
    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

  9. #8
    TechSupp's Avatar
    Join Date
    Mar 2007
    Location
    South Yorkshire
    Posts
    1,830
    Thank Post
    288
    Thanked 112 Times in 93 Posts
    Rep Power
    39
    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.

  10. #9

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,662
    Thank Post
    324
    Thanked 506 Times in 474 Posts
    Rep Power
    177
    Quote Originally Posted by TechSupp View Post
    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:

    Code:
    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.

    Code:
    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
    Last edited by Steve21; 14th October 2012 at 12:49 PM.

  11. #10


    Join Date
    Feb 2007
    Location
    51.405546, -0.510212
    Posts
    8,142
    Thank Post
    204
    Thanked 2,398 Times in 1,774 Posts
    Rep Power
    705
    Quote Originally Posted by CyberNerd View Post
    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.

  12. #11

    3s-gtech's Avatar
    Join Date
    Mar 2009
    Location
    Wales
    Posts
    2,502
    Thank Post
    134
    Thanked 493 Times in 441 Posts
    Rep Power
    140
    ^^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.

  13. #12

    Join Date
    Jun 2007
    Location
    Herts
    Posts
    186
    Thank Post
    89
    Thanked 30 Times in 27 Posts
    Rep Power
    38
    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.

  14. #13
    TechSupp's Avatar
    Join Date
    Mar 2007
    Location
    South Yorkshire
    Posts
    1,830
    Thank Post
    288
    Thanked 112 Times in 93 Posts
    Rep Power
    39
    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.

SHARE:
+ Post New Thread

Similar Threads

  1. Proxy: how to differentiate between Thinclient and Server
    By jmair in forum Thin Client and Virtual Machines
    Replies: 3
    Last Post: 7th March 2012, 09:35 PM
  2. Replies: 4
    Last Post: 15th November 2011, 11:24 AM
  3. Replies: 10
    Last Post: 6th November 2009, 11:12 PM
  4. Replies: 19
    Last Post: 5th December 2008, 12:26 PM
  5. Switching between Mac And PC with only one monitor
    By Kyle in forum How do you do....it?
    Replies: 9
    Last Post: 18th June 2008, 07:42 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •