Importing and Exporting Windows Network Settings

By Eric Geier (NoWiresSecurity Founder & Owner) - originally published on InformIT

 

This tutorial covers how to back up and/or transfer your network settings. We'll address these main network settings:

 

  • Wireless profiles. Encryption and authentication settings.

  • TCP/IP configuration. Static IP addresses and DNS details.

  • Wired profiles. 802.1X authentication settings.

 

The chief method we'll use is the network shell (Netsh) command-line tool, which works at the command prompt. Although Netsh has been included in Windows since Windows 2000, support for working with wireless and wired network profiles wasn't added until Windows Vista.

We'll also work with Windows Connect Now (WCN), available in Windows XP SP2 and later. Microsoft developed this feature to make it easier to set up and configure smaller networks.

Importing and Exporting Wi-Fi Settings with Netsh (Windows Vista and Windows 7 Only)

In Windows Vista and Windows 7, Microsoft includes wireless commands for the Netsh command-line tool. This feature gives you the ability to export the profiles of wireless networks you've saved in Windows; it also lets you import the profiles into other Vista or Windows 7 machines.

To get started with Netsh, open a command window. Since it's nice to know the profile name, you can first review a list of the saved profile names:

 

netsh wlan show profiles

 

If you want to see the details of your profiles, use this command:

 

netsh wlan show all

 

When you're ready to export a profile, use the following syntax:

 

netsh wlan export profile folder="PATH_TO_FOLDER" name=PROFILENAME

 

This command creates an XML file (Figure 1 shows an example) in the folder you specify, and using the name of the interface and the profile you enter (for example, Wireless Network Connection-mynetworkname.xml).

Keep in mind that you don't have to specify any parameters; you can simply enter the command:

netsh wlan export profileIf you don't provide a folder name, Windows will automatically choose the main directory of the user's personal folders. If you don't identify a profile name, Windows will export all the profiles.

TIP: After you've exported a profile, you can modify the network settings. Right-click the XML file and choose Open With > Notepad (or your favorite file editor). Then edit and save the file. Be careful not to mess up the schema in the XML file! If you're interested in editing a profile, check out the schema details from Microsoft's MSDN site.

After exporting a profile, you can import it into another Vista or Windows 7 machine:


netsh wlan add profile filename="PATH_AND_FILENAME.xml"

 

You can specify an interface to import the profile; this option is useful if the computer has multiple wireless adapters. You can also specify that you want to apply the profile to all users of the computer, or just to the current user. Here's an example using both parameters:

 

netsh wlan add profile filename="PATH_AND_FILENAME.xml" Interface="Wireless Network Connection" user=current

 

If you don't specify an interface, Windows adds it for all interfaces by default. Also, if you don't specify the user parameter, Windows adds the profile for all users.

Importing and Exporting Wired Authentication Settings with Netsh (Windows Vista and Windows 7 Only)
If you're running 802.1X authentication on a wired network, you might find it useful to export and import your wired network profile in Windows Vista or Windows 7. (If you want to back up or transfer the IP and DNS details, however, see the next section. The wired network profile consists of the authentication settings only.)

First, you can print a list of the wired profiles and their settings:

netsh lan show profilesThen, when you're ready to export a profile, use the following syntax:

 

netsh lan export profile folder=PATH_TO_FOLDER interface="INTERFACE_NAME"

 

This command creates an XML file (see Figure 2 for an example) in the folder you specify, and using the name of the specified interface; for example, Local Area Connection.xml.

Keep in mind that identifying an interface is optional. If you don't specify the interface, Windows exports the profiles for every interface. However, you must specify a folder.

You can import a wired profile into another Windows Vista or Windows 7 machine with this command:

 

netsh lan add profile filename="PATH_AND_FILENAME.xml" interface="INTERFACE_NAME"

 

Importing and Exporting TCP/IP Configuration with Netsh


If you assign static IP or DNS addresses to your computers, exporting and importing a TCP/IP configuration might be useful. You can archive the settings for backup purposes, or use the configuration as a template to configure other computers more quickly. For instance, you might configure a computer with the static IP and DNS details, export it, and then before importing it onto other computers simply change the IP address to avoid conflicting addresses.

NOTE: Remember that some settings, such as the interface names, may vary across different PCs.

To dump or export the TCP/IP configuration, use this command:

 

netsh -c interface dump > PATH_AND_FILENAME.txt

 

TIP: You can open and edit the configuration file in your favorite text editor (such as Notepad).


Use this command to import the TCP/IP configuration:

 

netsh -f PATH_AND_FILENAME.txt

 

Transferring Wi-Fi Network Settings via USB Flash Drive
Windows Connect Now (WCN) provides the ability to copy a wireless network profile to a USB flash drive so that you can easily distribute the network settings (name, WEP or WPA/WPA2-PSK encryption settings, etc.) to other wireless computers and devices that aren't connected yet.

To export wireless network profiles to a flash drive in Windows XP SP2 or SP3 and Windows Vista, you can use the Wireless Network Setup wizard. You can start this wizard from any of several shortcut locations. For example:

Click Start > Programs > Accessories > Communications > Wireless Network Setup.
Open the Control Panel, open the Network and Internet Connections folder, and then open Wireless Network Setup.
WPA/WPA2-Enterprise isn't support by Windows Connect Now, but you can use Netsh to back up or transfer network profiles using the WPA/WPA2 mode, as discussed earlier,.

To export wireless network profiles to a flash drive in Windows 7, first open the profile or wireless network connection settings. One simple way is to click the network icon in the system tray, right-click a network name, and select Properties. On the Connection tab, click "Copy this network profile to a USB flash drive."

To import the profile into a Windows XP, Vista, or 7 machine, insert the USB flash drive. When the AutoPlay dialog box appears, click the shortcut "Connect to a Wireless Network using Windows Connect Now," or click the "Wireless Network Setup Wizard" shortcut. If the AutoPlay menu doesn't appear, you can also initiate the import by running SetupSNK.exe on the flash drive's root directory.

Keep Your Settings Safe!

Now you know how to export and import all the main network settings. Remember to keep track of your backups or copies[md]the wireless settings, for instance, might include the keys to the network!