change wireless networks using cmd or batchfile? - batch-file

I need to create a batch file for my windows 7 to change from 1 wireless network (BigPondD1CBA1) to my (Home) Network. I have tried things such as google and all I have been able to find with relevant info .
http://www.hanselman.com/blog/HowToConnectToAWirelessWIFINetworkFromTheCommandLineInWindows7.aspx
netsh wlan connect ssid=Home name=Home interface="WIRELESS NETWORK CONNECTION"
I have tried
netsh wlan /?
But it seems as though I'm coding it correctly but must be missing a step ?
or I'm doing it wrong can someone please help or even just two batch files one to disconnect from my current wlan and one to connect to the other would be fine if some fine genius could help that would be great i think it shouldn't be a hard task but its out of my league thanks in-advance .

I was over thinking it the solution to change accesspoint is
netsh wlan connect name="accesspoint name"

Related

Batch script to enable a disabled network adapter with different names

I'm writing a script to revert the network settings back to default which is to switch back to DHCP on LAN and re-enable the wireless adapter. All these operations were done under the local admin rights privileges for all devices that I'm managing.
While the switching over to DHCP from static works, the script was unable to re-enable the wireless adapter and showing "No more data is available". I had did a bit of troubleshooting and found out that the disabled wireless adapter is not reflected in the ipconfig /all command which I have been using it to obtain the adapter name (e.g Wi-Fi, Wi-Fi 2, etc.) thus the netsh command gave the error due to the varible being invalid.
Here is the part of the code that's responsible for the re-enabling the wireless adapter back. I'm aware that if I were to enter the netsh interface set interface name="Wi-Fi" admin=enabled manually it works based on the adapter name that's taken on my test device. But however I can't hard-code the adapter name as it may not be the same for different devices. Do share if there's any other code for the first line that I might not be not aware of as I did many googling and it only came up with either for the ipconfig or wmic command. Thanks!
::Look for the Wi-Fi adapter name
for /f "tokens=* delims=:" %%b in ('ipconfig ^| find /i "Wireless LAN adapter Wi-Fi"') do set wifiadaptername=%%b
set wifiadaptername=%wifiadaptername:~21%
set wifiadaptername=%wifiadaptername:~0,-1%
::Switch on Wi-Fi
netsh interface set interface name="%wifiadaptername%" admin=enabled

How to force DHCP on all phyiscal ports, including Disconnected Media ports, with WMIC

Could anyone help me force all network adapters to be DHCP whether connected or disconnected.
I am relatively new and very novice in batch and I have been working on something to set fixed ipv4 details based on variable Ethernet adapter names. It has been cobbled together from other people's solutions to various problems on here. I am sure there are much more eloquent and elegant ways of doing this and happy to be pointed that way but I would like to try and figure this out.
The idea was to have a call batch script in the startup folder of a OOBE windows machine. Search the connected adapter, irrelevant of the name of said port, set the IP address as static and rest of the details were fixed. I wrote the batch in such a way as to create various IP profiles using variables to create the profile to set the fixed details i.e. a batch to write a batch
As an exercise I was thinking if I were to move the machine and plug in a different adapter on the same machine. How would I have a disconnected adapter with the IP address I want to use switch to DHCP. This would free up the address to search for connected adapter as per the rest of the script. This is where the script fails. I can have the connected adapter switch tp DHCP, disable and enable correctly.
WMIC NICConfig Where "IPEnabled='True' and DHCPEnabled='FALSE'" Call EnableDHCP
this works but only on the connected adapter.
But I am trying to flush out the IP address on the disconnected adapter to use on the connected adapter. So far I've tried
WMIC NICConfig Where NetConnectionID=7 Call EnableDHCP
returns a "Description = Invalid query"
WMIC NICConfig Where "PhysicalAdapter='True'" Call EnableDHCP
returns a "Description = Invalid query"
WMIC NICConfig Where "DHCPEnabled='FALSE'" Call EnableDHCP
returns {ReturnValue = 84;}; I thought this would search for adapters that were not DHCP and change to to be DHCP but I think the adapter has to be connected.
When I use
WMIC NICConfig Where "PhysicalAdapter='True'" Call /?
EnableDHCP looks to be an option but gives a "Description = Invalid query"
Is there a way to do what I am trying to do?
I can also post the entire script if anyone is interested in it but will leave it off until requested. Thanks in advance for any help.
I figured this out.
I was going about it the complete wrong way.
I was trying to clear all adapters fixed ip addresses by "forcing" the physical adapter to DCHP weather connected or disconnected.
But if I have had said
netsh int ip reset
wmic path win32_networkadapter where PhysicalAdapter=True call disable
wmic path win32_networkadapter where PhysicalAdapter=True call enable
This achieves what I want. This clears the IP, subnet and gateway. Sometimes the solution is much easier than expected.
Is there a way to clear the DNS information too for all physical adapters, without knowing their names, so that if IPV4 properties is open no information would be there?

How can I determine the type of internet connetion with a Batch script?

I'm looking for a way to determine whether my internet connection is based on wifi, ethernet, or cellular with a Batch script. My end goal is to have a script run on startup that determines what the connection type is, and as long as it isn't cellular, start a certain application. How can I determine the type of internet connection?
Thanks for any help or ideas!
(I'm a relative newbie at batch, so I would really appreciate all the detail you could give me)
wmic nic where "NetEnabled=TRUE" get description |find "Mobile Broadband" >nul && (
echo Mobile connection active
) || (
echo Mobile connection inactive
)
get all network adapters that are connected and look, if Mobile Broadband" is among them. Execute commands if yes (&&) and other commands, if not (||`)
You might need to adapt the string Mobile Broadband to your actual hardware.
Note: just because it's activ, it doesn't mean, your traffic runs through it; there might be more than one activ adapter.

Connect to an ad-hoc-network in windows 10 only via command line

I am currently writing a .bat script in which you can choose whether you want to create an ad-hoc-network or connect to one, to make it easy for everyone to connect within windows 8, 8.1 and 10 as the GUI setup was removed.
Well, creating was easy.
netsh wlan set hostednetwork mode=allow ssid=adhocnetwork key= password
netsh wlan start hosted network
pause
But when I want to connect to a network via netsh wlan connect adhocnetwork, it says there is no profile called 'adhocnetwork'.
I figured that you first have to create a profile with the network GUI.
So my question is now if there is a way to create a network profile with the command line, so that I can implement that into the bat file.
Thanks for every answer!
Best greetings,
Bant
Okay, well, here is my workaround.
Go to the network and sharing center (hope that's right, my system is in German)
Manually create wireless network and type in the name, security type and key.
Remove the tag from 'connect automatically'.
Press 'Done'
Now open the command line and type in the following lines:
netsh wlan set profileparameter name=%name% ConnectionType=IBSS
netsh wlan connect name=%name%
I am still hoping for a better solution where you don't need to leave the command shell.

DNS_PROBE_FINISHED_NXDOMAIN on Google App Engine website

For unknown reasons my website on Google App Engine is suddenly not loading anymore on multiple devices and in different browsers. It gives a DNS_PROBE_FINISHED_NXDOMAIN error. I tried restarting the DNS service, changing DNS to Google's, and restarting devices. Nothing helped so far. All other websites load without issues. What could be causing this?
Seems like there are some issues at my domain provider. Their website is giving the same error.
I've spent weeks fighting with this problem on 2 different unrelated computers, even unable to ping Yahoo.com and having variety of connectivity issues in web browsers, including "DNS_PROBE_FINISHED_NXDOMAIN" and "ERR_NAME_NOT_RESOLVED".
I've tried various ipconfig commands, restarting DNS client service, "netsh winsock reset", and other solutions found on the internet.
Finally I realized the only common thing on both my computers was Malwarebytes. After closing/exiting Malwarebytes the problem was solved.
I am now able to ping and access every website.
The solution, again, at least in my case: close Malwarebytes
I just contacted Malwarebytes support but in the meantime wanted to provide the solution here.
Run following command from cmd
ipconfig /release
ipconfig /all
ipconfig /flushdns
ipconfig /renew
netsh int ip set dns
netsh winsock reset ###( Need to run in administrator mode)
If not successful then
Restart your PC

Resources