Enable Ipv4 Autoconfiguration through Cmd - cmd

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

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

netsh interface ip set address "Wi-Fi" dhcp
netsh interface ip set dns "Wi-Fi" dhcp
netsh interface set interface "Wi-Fi" enable

Related

Resetting an IPV6 interface with powershell

Since netsh is going to become obsolete in the near future,I was looking for a replacement which does the equivalent to resetting the netsh ipv6 interface (netsh interface ipv6 reset).
I was looking for alternatives to run the above command either with powershell or any other script. On running netsh interface ipv6 reset,I can see alot of operations being performed,example:
Resetting Compartment Forwarding, OK!
Resetting Compartment, OK!
Resetting Control Protocol, OK!
I'm not sure how exactly to go about doing all of these with powershell or any other script.Is there any way to perform the above with powershell?
From going through the references online I understand that it overwrites the following registry,
Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\ to the default values.Where exactly is the default configuration for ipv6 stored?

NewNetIPAddress: ActiveStore vs. PersistantStore

I'm trying to set a new IP-Address by using a powershell script. I use this command:
New-NetIPAddress -InterfaceAlias $interfaceName -IPAddress $_.IPAddress -AddressFamily IPv4 -PrefixLength $maskLegth
However, on a disconnected interface i get this error:
New-NetIPAddress : Inconsistent parameters PolicyStore PersistentStore and Dhcp Enabled
But when i set the -PolicyStore to ActiveStore, the script will run without errors:
New-NetIPAddress -InterfaceAlias $interfaceName -IPAddress $_.IPAddress -AddressFamily IPv4 -PrefixLength $maskLegth -PolicyStore ActiveStore
I'm not quite sure what this property does, since after restart the settings still are in place. Are there any drawbacks here? Or why does this error even come up?
New-NetIPAddress : Inconsistent parameters PolicyStore PersistentStore and Dhcp Enabled
PersistentStore is separate from ActiveStore, and there is also separate GPO store.
These stores are firewall and network configurations.
ActiveStore contains configuration for this computer.
GPO store is configuration from local group policy.
Active store is curentlly active configuration, and includes both GPO and Persistent store.
Problem you are getting is because Persistent store is set to DHCP and you are configuring static address, which makes not sense.
first disable DHCP in active store and then set IP for interface.
For information about these stores and how to set them see:
https://learn.microsoft.com/en-us/powershell/module/netsecurity/set-netfirewallsetting?view=win10-ps

netsh wlan start hostednetwork. The hosted network started. Stuck #Obtaining ip address

I can create hosted network via following commands:
netsh wlan set hostednetwork mode=allow
netsh wlan set hostednetwork ssid=lol key=cse093007 keyusage=persistent
netsh wlan start hostednetwork
But I m stuck # Obtaining ip address.
I can't turn on those following Two:
FIPS 140-2 mode supported : No
802.11w Management Frame Protection supported : No
Interface name: Wi-Fi
Driver : 802.11n/b/g 2cm Wireless LAN USB2.0 Adapter
Vendor : AboCom System, Inc.
Provider : Microsoft
Date : 30-Mar-13
Version : 1086.51.328.2013
INF file : net8192su64.inf
Type : Native Wi-Fi Driver
Radio types supported : 802.11n 802.11g 802.11b
FIPS 140-2 mode supported : No
802.11w Management Frame Protection supported : No
Hosted network supported : Yes
Authentication and cipher supported in infrastructure mode:
Open None
WPA2-Personal CCMP
Open WEP-40bit
Open WEP-104bit
Open WEP
WPA-Enterprise TKIP
WPA-Personal TKIP
WPA2-Enterprise TKIP
WPA2-Personal TKIP
WPA-Enterprise CCMP
WPA-Personal CCMP
WPA2-Enterprise CCMP
Vendor defined TKIP
Vendor defined CCMP
Authentication and cipher supported in ad-hoc mode:
Open None
Open WEP-40bit
Open WEP-104bit
Open WEP
WPA2-Personal CCMP
Wireless Display Supported: No (Graphics Driver: No, Wi-Fi Driver: No)
Sometimes DHCP on windows Ad-Hoc takes too long to assign IP address or sometimes it fails to do so.
So if DHCP is not working properly, use static IP on the client side.
Type ipconfig in command prompt and find the IP address of an interface named Microsoft Hosted Network Virtual Adapter.
Now, in the client system, use that IP as the default gateway and give the client IP address with first 3 fields same as the default gateway and giving a different number in the 4th field.
eg:
Default Gateway : 192.168.43.1
IP Address of client : 192.168.43.3
This fixed my issue. I forgot to share my wifi to hostednetwork.
To share you wifi with hostednetwork;-
go to network adapter settings
right-click on your default wifi adapter
click on properties
go to sharing tab
check on allow other user to connect to this computer
in drop down menu select your hostednetwork
You can try using a static IP address in Phone Wifi settings. Try the following settings.
IP Address: 192.168.137.2
Gateway: 192.168.137.1
DNS1: 8.8.8.8
DNS2: 8.8.4.4
The following procedure worked for me (windows 8.1)
1) Disable Internet Connection Sharing from your modem connection -> properties -> Sharing Tab
2) Enable it again.
3) Disconnect from the Internet.
4) Reconnect again
5) Restart ICS service from the "services.msc" window.
6) Stop the hostednetwork
7) Start the hostednetwork
8) Internet Sharing is now enabled and everything gets resolved.
Credit goes to Vekool
it also worked for me.
from here: https://superuser.com/questions/804227/how-to-get-assigned-ips-by-hostednetwork
I've also had this problem, and I solved it like this:
create a WiFi hotspot:
netsh wlan set hostednetwork mode=allow ssid=ProvaMi key=pippo123
netsh wlan start hostednetwork
Assign the hotspot a name in the "Network and sharing center > change adapter settings" (in my case: "TestWIFI")
Set a static IP address for the WiFi network:
netsh interface ip set address "TestWIFI" static 192.168.159.1 255.255.255.0 196.168.159.1
Now, using a program that provides a DHCP server on windows (http://www.dhcpserver.de/cms/), I configured the server to generate the
[SETTINGS]
IPPOOL_1=192.168.159.2-254
IPBIND_1=192.168.159.1
AssociateBindsToPools=1
Now, the DHCP server will update its own settings file (dhcpsrv.ini) with the IP address and the DNS name of any connected client.
Hope this helps.
Note: all the above (IP addresses, passwords, etc.) are examples for my test configuration. Of course you'd need to use your own settings.
Simply restarting the ICS service from the "services.msc" window will fix this. After which,
run:
netsh wlan stop host
netsh wlan start host

How to create WIFI hotspot with second Wifi adapter

I am currently developing an application for machines where we will need two wifi connections. The first one to be connected to a box (hardware data) and the other one for exchanging data between machines.
We have two wifi modules, the internal wifi card and an external USB wifi module (more powerful).
We would like to convert the strong external wifi to a Hotspot. The problem is, Windows creates by default the hotspot on the internal wifi adapter. Then the reception is weaker than if it was created on the external module.
I create the hospot with the following command lines:
netsh wlan set hostednetwork mode=allow
netsh wlan start hostednetwork
I even tried to disable the internal adapter but Windows still creates the hotspot on the internal adapter.
netsh interface set interface name="Internal Network" admin=disabled
netsh wlan set hostednetwork mode=allow
netsh wlan start hostednetwork
netsh interface set interface name="Internal Network" admin=enabled
I looked up everywhere and nobody seems to have an idea (or they just post back these very command lines without understanding the point).
Does anyone have an idea? Having the weak internal adapter signal is not an option.
After some verification it seems the driver the manufacturer gave me was the wrong version. "netsh wlan show drivers" gave me:
Hosted network supported: No
After communicating with them, they shipped the right driver version.

Setting up our new Dev server What is the easiest way to assign multiple IP addresses

I'm setting up our new Dev server, what is the easiest way to assign multiple IP addresses to Windows 2008 Server Network Adapter?
I'm setting up our development machine, running IIS 7 and want to have the range between 192.168.1.200 - .254 available when I'm setting up a new website in IIS 7.
The complete CMD.EXE loop:
FOR /L %b IN (200,1,254) DO netsh interface ip add address "your_adapter" 192.168.1.%b 255.255.255.0
In the code above, replace "your_adapter" with the actual interface name (usually "Local Area Connection"). In addition, the netmask at the end is an assumption of /24 or Class C subnet; substitute the correct netmask.
> netsh interface ipv4 add address "Local Area Connection" 192.168.1.201 255.255.255.0
Wrap in a cmd.exe "for" loop to add multiple IPs.
EDIT: (from Brian) "Local Area Connection" above is a placeholder, make sure you use the actual network adapter name on your system.
Network Connections -> Local Area Network Connection Properties -> TCP/IP Properties -> Advanced -> IP Settings -> Add Button.

Resources