0

At school I've got a Wifi configured with Isa authentication. So everytime I have to connect my laptop with it, I have to configure the static ip address (Network adapter -> Ipv4 properties) and enable the proxy (internet settings -> Lan Settings -> Proxy) in order to get access to the internet. However the process is easy but it's kind of sticky. The whole thing takes up to around 1 to 2 minutes, and when I'm back home I have to disable all the settings in order to use my home Wifi.

So I decided to make 2 scripts in order to automatize enabling and disabling of the process explained above.

I'm using AutoIt for the purpose.

I've already done the script in order to enable the ipv4 settings using cmd's netsh command.

For the proxy stuff i've used a registry script in order to:

Enable, Modify, Disable

So for the proxy it's all easy. My problem is disabling the static ipv4 configuration. The reset command for netsh is not working cause that just removes the static settings butt does not turn on the automatic configuration.

Image describing problem:

enter image description here

What I want to achieve is somehow enable those 2 radio buttons through cmd script or any registry script. And I repeat again the netsh reset command just removes all the static ip's but does not enable the automatic ip settings!

How can I achieve this?

DavidPostill
  • 7,734
  • 9
  • 41
  • 60
Majid701
  • 19
  • 1
  • 5
  • Can't test it on my notebook because of missing admin rights. But did you try to use this NetSetMan? – Xenobiologist Jan 21 '15 at 12:48
  • @Xenobiologist Thanks for the Advice that is a pretty nice software. But i still wan't to do it through cmd without using a third party program. – Majid701 Jan 21 '15 at 16:36
  • Have you tried an alternate configuration for school? i.e. On the general tab, use DHCP (automatic), then you should have a 2nd tab where you can enter the static IP address and settings for school. I think you might be going to a lot of effort for something that is easily configured in the normal TCP properties window. – Scott C Jan 22 '15 at 09:43
  • @ScottC Can you explain better please? – Majid701 Jan 22 '15 at 20:12
  • Have a read of https://technet.microsoft.com/en-us/library/cc725638.aspx and http://www.tomshardware.com/faq/id-1926331/alternate-address-configuration.html. I have certainly used this successfully before when I needed a fixed IP address for the office and DHCP at home. In short, if your PC can't get an IP through the DHCP lookup (i.e. you're not at home) then it uses the alternate tab values instead (for school). – Scott C Jan 23 '15 at 02:39
  • @ScottC That's what i already do. And it works. What i want to achieve is automate the process of ipconfiguration creating a script called "enableProxy" and delete the values inserted with a script called "disableProxy" saving those 5-10 minutes of everyday job. Anyways my school has removed all the access points soo i don't need this anymore. Although i went successfull creating the script with AutoIt using the button clicks at the end. I changed the script mousecoord mode to window type in order to avoid dependency to the screen resolution, and passed it to my classmates. – Majid701 Feb 25 '15 at 07:38

2 Answers2

0

Command netsh int ip reset is supposed to reset TCP/IP networking as a whole when normal configuration or even networking in general does not work anymore, and seem to require a reboot to work. This is not recommended for your purposes.

Instead you need your computer configured to obtain network configuration from DHCP-server, which is a program that probably runs on your wireless router.

IP-address

In examples below please substitute Wi-Fi with network adaptor name as specified in Network connections control panel window. Yours seems to be named Connettione nete wireless so replace Wi-Fi with that but keep double quotes. If you need to obtain that name automatically please refer to this question.

Following commands reset configuration to Obtain an IP address automatically and Obtain DNS server address automatically:

netsh interface ipv4 set address name="Wi-Fi" source=dhcp
netsh interface ipv4 set dnsservers name="Wi-Fi" source=dhcp

Following commands configure static IP address and DNS-servers:

netsh interface ipv4 set address name="Wi-Fi" static 192.168.1.2 255.255.255.0 192.168.1.1
netsh interface ipv4 set dns name="Wi-Fi" static 8.8.8.8
netsh interface ipv4 set dns name="Wi-Fi" static 8.8.4.4 index=2

The order of addresses in above example is the same as in the network configuration window.

For more information you may read these: DHCP, DNS, static IP

Proxy server

To enable proxy server (the global one in Internet properties)

reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" ^
/v ProxyEnable /t REG_DWORD /d 1 /f

To disable proxy:

reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" ^
/v ProxyEnable /t REG_DWORD /d 0 /f

If this does not work please try other solutions here.

Some programs may not use system-wide proxy settings and thus require additional configuration. For example this question deals with Firefox.

Enable/disable wireless

Following command is useful to enable the wireless adaptor if it was disabled beforehand (i.e. to conserve battery life):

netsh interface set interface name="Wi-Fi" admin=ENABLED

And this is how to disable it:

netsh interface set interface name="Wi-Fi" admin=DISABLED
Jack White
  • 896
  • 5
  • 7
0
netsh interface ip set address "Wi-Fi" dhcp
netsh interface ip set dns "Wi-Fi" dhcp
netsh interface set interface "Wi-Fi" enable
YouneS
  • 390
  • 4
  • 10