Archive

Archive for March, 2014

Forgetting Wireless Networks In Windows 8.1

March 30, 2014 Comments off

One of the problems with Windows 8 is that it hides important functionality. For instance, Windows 7 had a useful “Manage Wireless Networks” section of the Network and Sharing Center, but that was removed in Windows 8. The ability to delete a saved wireless connection did remain, albeit only when the connection showed up in the network list, where you could right-click it to delete it. Then Windows 8.1 came along and removed even that feature.

The good news is that the command-line utility netsh can still be used to forget the networks. You can type netsh wlan show profiles to display a list of saved networks, and netsh wlan delete profile name="profilename" (where profilename is the name of the saved network connection) to forget one. See Ciprian Adrian Rusen’s post on 7 Tutorials entitled How to Delete or Forget Wireless Network Profiles in Windows 8.1 for more details. That’s not much consolation, however, for users who aren’t comfortable using the command line.

To help mitigate this problem, I put together a batch file that acts a bit like a wizard to automate the process. It starts by displaying the list of profiles, asks the user whether to delete a profile, and prompts for the name of the profile to delete. It’s nothing fancy, but it might be easier to double-click a batch file and follow instructions than remember the netsh command.

A couple of caveats: First, I generally recommend against running just any batch file you found on the Internet unless you’ve had a chance to look it over and have at least some understanding of what it’s doing. That’s part of the reason that I’m not offering a separate download: If you copy-paste the code yourself, at least you know I didn’t slip anything in there that wasn’t in this post for everyone to see. Second, I’m offering this with absolutely no warranties whatsoever (see disclaimer below). I’m not sure what could go wrong, except maybe deleting a profile you didn’t mean to delete, but it wouldn’t be the first time I made something that failed in ways I didn’t think it could.

Here’s the code:

@echo off

:BEGIN

echo Listing saved wireless network profiles...
netsh wlan show profiles
set /p deleteconf="Delete a profile (Y/N)? > " %=%
IF %deleteconf%==Y ( goto DELETEPROMPT ) ELSE (
    IF %deleteconf%==y ( goto DELETEPROMPT ) ELSE ( goto END )
)

:DELETEPROMPT

set /p ssid="Delete which network? > "
netsh wlan delete profile name="%ssid%"

GOTO BEGIN

:END
echo Exiting.
pause

Just copy the above code and paste it into a text editor such as Notepad, then save it as something with the .bat extension. (When saving, make sure you set the “Save as type” field to “All files (*.*)” or else you’ll end up with a plain text file.) Double-click the batch file to run it. It will start by showing you a list of saved wireless network profiles. It will then ask whether you want to delete one. Type Y and hit enter, then type the name of the profile you want to delete and hit enter again. Repeat until you’re finished deleting networks, then type N at the prompt to exit.

Screenshot of the batch file running

Feel free to use and distribute this however you please. I’m not going to bother formally open-sourcing it because I don’t think there’s enough to it to warrant including a license longer than the actual code. However, I am going to borrow the disclaimer from the BSD license (which, according to Wikipedia, is public domain, so copy-pasting it here shouldn’t be a copyright issue).

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Lest there be any confusion, “This software” means only the batch file itself, since of course I don’t own netsh itself, and “the copyright holders and contributors” just means me in this case.

I hope someone out there finds this useful.