Windows command to reconnect to Wifi & to "repair" wireless NIC

Very often our Wifi's quality would deteriorate & often the wireless connection just drops:
this happens not only on my Win XP laptop but my other colleagues' Win 7 laptops too.

We don't have access to the Wifi as it's operated by the building's landlord & usually
complaints go unheeded.

Q1:
Attached is a script : the "netsh" portion appears to be of incorrect syntax, can anyone
correct it or fix it?

Q2:
Most of the times, I'll need to right-click on my Wifi little icon (on the bottom right
corner) & select "Repair" & it would reconnect back to either one of the Ssid ie
Wifi  or  Wifi2  shown in the attached script.  What's the exact command to perform
this "Repair" on the Wireless NIC ?

Q3:
if we don't have access to the broadband router (ie I can't get a signal booster to
connect to it), is there any way I could boost the signal scanning on my laptop
instead?


Any other suggestions are most welcome: my objective is simply to recover the
Wifi connection if it drops or prevent it from dropping.   Can't reach the AP /
broadband router to troubleshoot so relying on means at the users/laptop end
ReconnectWifi.txt
sunhuxAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

JohnBusiness Consultant (Owner)Commented:
If the profile is good and it cannot connect, then just leave it. There is no need in this case to manage the connection.

If the profile is suspect, then delete the profile with netsh.  netsh wlan delete profile name="name with spaces"

Then remake the profile. I do this.  I think that is all you need to do.
JohnBusiness Consultant (Owner)Commented:
You could if you like (assuming a good profile) have a script that does the following In addition to the above.

netsh wlan disconnect profile followed by
netsh wlan connect profile
sunhuxAuthor Commented:
Is the syntax for Win 7 or Win XP?   On my
Win XP, it says "command not found"
Cloud as a Security Delivery Platform for MSSPs

Every Managed Security Service Provider (MSSP) needs a platform to deliver effective and efficient security-as-a-service to their customers. Scale, elasticity and profitability are a few of the many features that a Cloud platform offers. View our on-demand webinar to learn more!

JohnBusiness Consultant (Owner)Commented:
Sorry the disconnect parameter is interface.   netsh wlan disconnect interface  

Use netsh wlan /?  to see all the possible commands and the way they are used.

Then netsh wlan interface /?  to see how it is used.
sunhuxAuthor Commented:
C:\>netsh wlan connect "mycloud"
The following command was not found: wlan connect mycloud.

C:\>netsh wlan connect mycloud
The following command was not found: wlan connect mycloud.

C:\>netsh /?

Usage: netsh [-a AliasFile] [-c Context] [-r RemoteMachine]
             [Command | -f ScriptFile]

The following commands are available:

Commands in this context:
?              - Displays a list of commands.
add            - Adds a configuration entry to a list of entries.
bridge         - Changes to the `netsh bridge' context.
delete         - Deletes a configuration entry from a list of entries.
diag           - Changes to the `netsh diag' context.
dump           - Displays a configuration script.
exec           - Runs a script file.
firewall       - Changes to the `netsh firewall' context.
help           - Displays a list of commands.
interface      - Changes to the `netsh interface' context.
lan            - Changes to the `netsh lan' context.
ras            - Changes to the `netsh ras' context.
routing        - Changes to the `netsh routing' context.
set            - Updates configuration settings.
show           - Displays information.
winsock        - Changes to the `netsh winsock' context.

The following sub-contexts are available:
 bridge diag firewall interface lan ras routing winsock

To view help for a command, type the command, followed by a space, and then
 type ?.

C:\>
C:\>
C:\>netsh help

The following commands are available:

Commands in this context:
?              - Displays a list of commands.
add            - Adds a configuration entry to a list of entries.
bridge         - Changes to the `netsh bridge' context.
delete         - Deletes a configuration entry from a list of entries.
diag           - Changes to the `netsh diag' context.
dump           - Displays a configuration script.
exec           - Runs a script file.
firewall       - Changes to the `netsh firewall' context.
help           - Displays a list of commands.
interface      - Changes to the `netsh interface' context.
lan            - Changes to the `netsh lan' context.
nap            - Changes to the `netsh nap' context.
ras            - Changes to the `netsh ras' context.
routing        - Changes to the `netsh routing' context.
set            - Updates configuration settings.
show           - Displays information.
winsock        - Changes to the `netsh winsock' context.

The following sub-contexts are available:
 bridge diag firewall interface lan nap ras routing winsock

To view help for a command, type the command, followed by a space, and then
 type ?.


C:\>netsh
netsh>interface ?

The following commands are available:

Commands in this context:
?              - Displays a list of commands.
add            - Adds a configuration entry to a table.
delete         - Deletes a configuration entry from a table.
dump           - Displays a configuration script.
help           - Displays a list of commands.
ip             - Changes to the `netsh interface ip' context.
ipv6           - Changes to the `netsh interface ipv6' context.
portproxy      - Changes to the `netsh interface portproxy' context.
reset          - Resets information.
set            - Sets configuration information.
show           - Displays information.

The following sub-contexts are available:
 ip ipv6 portproxy

To view help for a command, type the command, followed by a space, and then
 type ?.

netsh>
sunhuxAuthor Commented:
netsh>lan
netsh lan>?

The following commands are available:

Commands inherited from the netsh context:
..             - Goes up one context level.
abort          - Discards changes made while in offline mode.
add            - Adds a configuration entry to a list of entries.
alias          - Adds an alias.
bridge         - Changes to the `netsh bridge' context.
bye            - Exits the program.
commit         - Commits changes made while in offline mode.
delete         - Deletes a configuration entry from a list of entries.
diag           - Changes to the `netsh diag' context.
exit           - Exits the program.
firewall       - Changes to the `netsh firewall' context.
interface      - Changes to the `netsh interface' context.
lan            - Changes to the `netsh lan' context.
nap            - Changes to the `netsh nap' context.
offline        - Sets the current mode to offline.
online         - Sets the current mode to online.
popd           - Pops a context from the stack.
pushd          - Pushes current context on stack.
quit           - Exits the program.
ras            - Changes to the `netsh ras' context.
routing        - Changes to the `netsh routing' context.
set            - Updates configuration settings.
show           - Displays information.
unalias        - Deletes an alias.
winsock        - Changes to the `netsh winsock' context.

Commands in this context:
?              - Displays a list of commands.
add            - Adds a configuration entry to a table.
delete         - Deletes a configuration entry from a table.
dump           - Displays a configuration script.
export         - Saves LAN profiles to XML files.
help           - Displays a list of commands.
reconnect      - Reconnects on an interface.
set            - Configures settings on interfaces.
show           - Displays information.

To view help for a command, type the command, followed by a space, and then
 type ?.

netsh lan>
sunhuxAuthor Commented:
netsh interface>show interface

Admin State    State          Type             Interface Name
-------------------------------------------------------------------------
Enabled                       Dedicated        Local Area Connection
Enabled                       Dedicated        Wireless Network Connection
Enabled                       Internal         Internal
Enabled                       Loopback         Loopback

netsh interface>
JohnBusiness Consultant (Owner)Commented:
netsh wlan disconnect interface="name of connection"  should work.
sunhuxAuthor Commented:
Disconnect & reconnect usually won't help;  I usually have to right-click on
the Wifi interface & select "repair" : what's the equivalent command to be
run in the batch script for "repair"?
JohnBusiness Consultant (Owner)Commented:
To repair a Wi-Fi connection you need to delete it and then remake it.
sunhuxAuthor Commented:
Bear with me, so what's the exact command syntax for Win XP  ( & Win 7 as well)?
JohnBusiness Consultant (Owner)Commented:
Windows Vista, Windows 7, Windows 8 and Windows 10 are all the same and as I showed. I am not sure about XP but I think the commands are the same.
sunhuxAuthor Commented:
Sorry, I'm still missing the command & got the error below on both Win 7 & Win XP:
  netsh delete interface "WirelessNIC"
  The following command was not found: delete interface WirelessNIC
JohnBusiness Consultant (Owner)Commented:
For delete (as distinct from disconnect) the syntax is as follows:

netsh wlan delete profile name="Profile Name"

netsh is a command driven method and needs exact commands.
sunhuxAuthor Commented:
The "wlan"  keyword doesn't appear to be a valid keyword.

I think simply disabling & reenabling back is what I need.

Following 2 are quite close to re-enabling but still cant get it right:


C:\GC>netsh interface set interface name=WirelessNIC admin=DISABLED
One or more essential parameters not specified
The syntax supplied for this command is not valid. Check help for the correct sy
ntax.

Usage set interface [name = ] IfName
            [ [admin = ] ENABLED|DISABLED
              [connect = ] CONNECTED|DISCONNECTED
              [newname = ] NewName ]

      Sets interface parameters.

      IfName  - the name of the interface
      admin   - whether the interface should be enabled (non-LAN only).
      connect - whether to connect the interface (non-LAN only).
      newname - new name for the interface (LAN only).

      Notes:
      - At least one option other than the name must be specified.
      - If connect = CONNECTED is specified, then the interface
        is automatically enabled even if the admin = DISABLED
        option is specified.
 
======================================================

C:\GC>netsh interface set interface WirelessNIC DISABLED
One or more essential parameters not specified
The syntax supplied for this command is not valid. Check help for the correct sy
ntax.

Usage set interface [name = ] IfName
            [ [admin = ] ENABLED|DISABLED
              [connect = ] CONNECTED|DISCONNECTED
              [newname = ] NewName ]

      Sets interface parameters.

      IfName  - the name of the interface
      admin   - whether the interface should be enabled (non-LAN only).
      connect - whether to connect the interface (non-LAN only).
      newname - new name for the interface (LAN only).

      Notes:
      - At least one option other than the name must be specified.
      - If connect = CONNECTED is specified, then the interface
        is automatically enabled even if the admin = DISABLED
        option is specified.
sunhuxAuthor Commented:
http://stackoverflow.com/questions/19831023/enable-disable-network-connection-from-command-line

Link above was quite close but I still could not get it working:
C:\GC>netsh interface set interface name="WirelessNIC" admin=disabled
One or more essential parameters not specified
The syntax supplied for this command is not valid. Check help for the correct sy
ntax.

Usage set interface [name = ] IfName
            [ [admin = ] ENABLED|DISABLED
              [connect = ] CONNECTED|DISCONNECTED
              [newname = ] NewName ]

      Sets interface parameters.

      IfName  - the name of the interface
      admin   - whether the interface should be enabled (non-LAN only).
      connect - whether to connect the interface (non-LAN only).
      newname - new name for the interface (LAN only).

      Notes:
      - At least one option other than the name must be specified.
      - If connect = CONNECTED is specified, then the interface
        is automatically enabled even if the admin = DISABLED
        option is specified.
JohnBusiness Consultant (Owner)Commented:
Strange. wlan is valid on all systems I use.

Open cmd.exe and type netsh wlan /?    (use an admin command prompt - right click on cmd.exe and Run as Administrator)

What answer do you get?

The commands you showed do not work for me either.

I do not make this as complicated as you have made.

If a profile works, leave it - no need to repair.
If a profile does not work, delete It and make a new one . Delete DOES work - I use it
sunhuxAuthor Commented:
C:\>netsh wlan /?
The following command was not found: wlan /?.


C:\>netsh /?

Usage: netsh [-a AliasFile] [-c Context] [-r RemoteMachine]
             [Command | -f ScriptFile]

The following commands are available:

Commands in this context:
?              - Displays a list of commands.
add            - Adds a configuration entry to a list of entries.
bridge         - Changes to the `netsh bridge' context.
delete         - Deletes a configuration entry from a list of entries.
diag           - Changes to the `netsh diag' context.
dump           - Displays a configuration script.
exec           - Runs a script file.
firewall       - Changes to the `netsh firewall' context.
help           - Displays a list of commands.
interface      - Changes to the `netsh interface' context.
lan            - Changes to the `netsh lan' context.
ras            - Changes to the `netsh ras' context.
routing        - Changes to the `netsh routing' context.
set            - Updates configuration settings.
show           - Displays information.
winsock        - Changes to the `netsh winsock' context.

The following sub-contexts are available:
 bridge diag firewall interface lan ras routing winsock

To view help for a command, type the command, followed by a space, and then
 type ?.
sunhuxAuthor Commented:
The above is for my 32bit Win XP.

For my Win 7, it appears to have that feature:

C:\>netsh wlan /?

C:\>netsh wlan /?

The following commands are available:                                                                                                                         Commands in this context:                                                      ?              - Displays a list of commands.                                  add            - Adds a configuration entry to a table.                        connect        - Connects to a wireless network.                               delete         - Deletes a configuration entry from a table.                   disconnect     - Disconnects from a wireless network.                          dump           - Displays a configuration script.                              export         - Saves WLAN profiles to XML files.                             help           - Displays a list of commands.                                  refresh        - Refresh hosted network settings.                              reportissues   - Generate WLAN smart trace report.                             set            - Sets configuration information.                               show           - Displays information.                                         start          - Start hosted network.                                         stop           - Stop hosted network.                                                                                                                         To view help for a command, type the command, followed by a space, and then     type ?.
sunhuxAuthor Commented:
I'll need to use Win XP unless I reinstall my old 32bit 1GB
laptop to run Win 7 : I'll need to source for a Win 7 license
too which is a challenge
JohnBusiness Consultant (Owner)Commented:
XP does not have the WLAN commands as you said and I just verified with my own XP virtual machine.

So you will have to manage the Wi-Fi with the Windows or Third Party tool provided. There is not a command mode in XP to do what you want.
JohnBusiness Consultant (Owner)Commented:
I had some time to take another look. There are just no Wireless commands in XP like there is in Windows 7, 8 and 10. All the commands I have used with netsh in supported operating systems are for wired connections only in XP. So you cannot do what you want in XP. Not possible. You must use the tool that comes with the wireless card.
sunhuxAuthor Commented:
Or is there any 3rd party tool that could do this or what's the tool that comes with
Dell D420 Wifi card?
sunhuxAuthor Commented:
That laptop has a 100GB HDD & 1GB RAM, wonder if they're enough for Win 7?
JohnBusiness Consultant (Owner)Commented:
1 GB of memory is bare minimum for 32-bit. You need 2 GB for 64-bit.

You would have to look on the Dell CD that came with the card. I have done this for friends and the card comes with an installation CD or disk that has the tools.
sunhuxAuthor Commented:
Any idea where I could download this Dell CD utility online?

I don't have the CD anymore
oBdACommented:
Laptops often come with a little hardware switch that shuts off the wireless components; have you looked for that?
Does it help if you disable and re-enable the WiFi card in Device Manager?
If this helps, you can download devcon.exe (still available for XP; just drop it into the system32 folder) and use that to script it:
The DevCon command-line utility functions as an alternative to Device Manager
https://support.microsoft.com/en-us/kb/311272
To find the device ID in a command prompt:
devcon.exe find * | find.exe /i "<Some part of the WiFi's device name>"
Copy the device id matching your WiFi card (should look similar to that: "PCI\VEN_8086&DEV_4230&...") into the clipboard, and paste it instead of "<DeviceID>" into the script below; make sure you keep the double quotes around the whole string, and the "@" at the beginning:
devcon.exe disable "@<DeviceID>"
devcon.exe enable "@<DeviceID>"

As far as upgrading is concerned: you probably won't be happy with Win7 on that machine, as Win7 is pretty resource intensive. If you find a license for cheap, install it somehow, activate it, then do the free upgrade to Win10, or look for a Win8 license (I got Win8 running on a Netbook with an Atom 1.6GHz, 2GB and an 80GB SSD, and it has about the same performance as the XP that was on there before).
You will want to replace the HD with an SSD as well (assuming the machine isn't so old it still has a PATA interface, at which point you should just give up and buy a new one), and especially check if you can upgrade the RAM; even the older ones should support at least 2GB. If you're lucky, Dell still has documentation on how to do hardware upgrades on your model.
To find what type of RAM you have, you can use http://www.hwinfo.com/

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Wireless Networking

From novice to tech pro — start learning today.