Netsh Commands for All Contexts
Applies To: Windows Server 2008
Netsh uses the following standard commands in all contexts that you can run from a Netsh.exe command prompt (that is, netsh>).
Following is the list of netsh commands that you can run in all netsh contexts. To view the command syntax, click a command:
..
abort
add helper
alias
bye
commit
delete helper
dump
exec
exit
help
offline
online
popd
pushd
quit
set file
set machine
set mode
show
unalias
Moves to the context that is one level up.
..
- /?
Displays help at the command prompt.
Discards any changes made in offline mode. Abort has no effect in online mode.
abort
- /?
Displays help at the command prompt.
Installs the helper dynamic-link library (DLL) in netsh.
add helper DLLName
- DLLName
Required. Specifies the name of the helper DLL that you want to install.
- /?
Displays help at the command prompt.
Adds an alias that consists of a user-defined character string, which netsh treats as equivalent to another character string. Used without parameters, alias displays all available aliases.
alias[AliasName] [String1 [String2 ...]]
- alias[ AliasName]
Displays the specified alias.
- alias[ AliasName][ String1[ String2...]]
Sets AliasName to the specified strings.
- /?
Displays help at the command prompt.
The following netsh sample script sets two netsh aliases, Shaddr and Shp, and then leaves the Netsh command prompt in the Interface IP context:
alias shaddr show interface ip addr
alias shp show helpers
interface ip
If you type shaddr at the Netsh command prompt, Netsh.exe interprets this as the command show interface ip addr. If you type shp at the Netsh command prompt, Netsh.exe interprets this as the command show helpers.
Exits Netsh.exe.
bye
- /?
Displays help at the command prompt.
Commits any changes made in the offline mode to the router. Commit has no effect in online mode.
commit
- /?
Displays help at the command prompt.
Removes the helper DLL from netsh.
delete helperDLLName
- DLLName
Required. Specifies the name of the helper DLL that you want to uninstall.
- /?
Displays help at the command prompt.
Creates a script that contains the current configuration. If you save this script to a file, you can use the file to restore configuration settings that have been changed. Used without parameters, dump displays all of the netsh context configurations.
dump [FileName]
- [ FileName]
Specifies the name of the file to which you want to redirect output.
- /?
Displays help at the command prompt.
Loads a script file and runs commands from it.
execScriptFile
- ScriptFile
Required. Specifies the name of the script that you want to load and run.
- The ScriptFile can run on one or more computers.
Exits Netsh.exe.
exit
- /?
Displays help at the command prompt.
Displays help.
{/? | ? | help | h}
- none
Sets the current mode to offline.
offline
- /?
Displays help at the command prompt.
Changes that you make in this mode are saved, but you must run the commit or online command to set the changes in the router.
When you switch from offline mode to online mode, changes that you made in offline mode are reflected in the configuration that is currently running.
Changes that you make in online mode are immediately reflected in the configuration that is currently running.
Sets the current mode to online.
online
- /?
Displays help at the command prompt.
Changes that you make in online mode are immediately reflected in the configuration that is currently running.
When you switch from offline mode to online mode, changes that you made in offline mode are reflected in the configuration that is currently running.
Restores a context from the stack.
popd
- /?
Displays help at the command prompt.
- Used in conjunction with pushd, popd enables you to change the context, run the command in the new context, and then resume the prior context.
The following sample script changes a context from the root context to the interface ip context, adds a static IP route, and then returns to the root context:
netsh>
pushd
netsh>
interface ip
netsh interface ip>
set address local static 10.0.0.9 255.0.0.0 10.0.0.1 1
netsh interface ip>
popd
netsh>
Saves the current context on a first-in-last-out (FILO) stack.
pushd
- /?
Displays help at the command prompt.
- Used in conjunction with popd, pushd enables you to change the context, run the command in the new context, and then resume the prior context.
Exits Netsh.exe.
quit
- /?
Displays help at the command prompt.
Copies the command prompt window output to a file.
set file [ mode= ]{openFileName | appendFileName | close}
- openFileName**
Sends the command prompt window output to the specified new file.
- appendFileName**
Appends the command prompt window output to the specified existing file.
- close
Stops sending output and closes a file.
- /?
Displays help at the command prompt.
- If the specified FileName does not currently exist, netsh creates a new file with that name. If the specified FileName does currently exist, netsh overwrites the existing data.
To create a new log file called Session.log and copy all succeeding netsh input and output to Session.log, type:
set file open c:\session.log
Specifies the computer on which to perform configuration tasks. Used without parameters, the local computer is configured.
set machine [ name= ]ComputerName [ user= ][[ DomainName**\**]UserName ] [ pwd= ][Password | *]
- ComputerName
Required. Specifies the name of the computer on which to run subsequent netsh commands.
- DomainName
Optional. Specifies the domain name where the user account is located. If not specified, the user account must reside in the local domain or on the local computer.
- UserName
Optional. Specifies the user account name that has privileges to configure the specified computer.
- Password
Optional. Specifies the password for the designated user account.
- /?
Displays help at the command prompt.
- You can run commands on multiple computers from a single script by using set machine more than once in the script. For example, you can use set machine in a script to specify a destination computer (Computer A), and then any additional commands you add to the script will run on Computer A. You can then use set machine again in the same script to specify another destination computer (Computer B), and then any additional commands you add to the script will run on Computer B.
Sets the netsh mode to online or offline. Either offline or online must be specified.
set mode [ mode= ] {online | offline}
- online
Sets the current mode to online. In online mode, netsh commands are run immediately after you type them and press Enter.
- offline
Sets the current mode to offline. In offline mode, netsh commands are saved and can be run with the commit command.
- /?
Displays help at the command prompt.
Displays alias, helper, and mode information.
show {alias | helper | mode}
- alias
Lists all defined aliases.
- helper
Lists all top-level helpers.
- mode
Displays the current mode.
- /?
Displays help at the command prompt.
Deletes the specified alias.
unaliasAliasName
- AliasName
Required. Specifies the name of the alias that you want to delete.
- /?
Displays help at the command prompt.