(0) exportieren Drucken
Alle erweitern

Netsh Commands for All Contexts

Letzte Aktualisierung: Februar 2008

Betrifft: 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>).

Netsh standard commands

Following is the list of netsh commands that you can run in all netsh contexts. To view the command syntax, click a command:

..

Moves to the context that is one level up.

Syntax

..

Parameters
/?
Displays help at the command prompt.

abort

Discards any changes made in offline mode. Abort has no effect in online mode.

Syntax

abort

Parameters
/?
Displays help at the command prompt.

add helper

Installs the helper dynamic-link library (DLL) in netsh.

Syntax

add helper DLLName

Parameters
DLLName
Required. Specifies the name of the helper DLL that you want to install.

/?
Displays help at the command prompt.

alias

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.

Syntax

alias[AliasName] [String1 [String2 ...]]

Parameters
alias[ AliasName]
Displays the specified alias.

alias[ AliasName][ String1[ String2...]]
Sets AliasName to the specified strings.

/?
Displays help at the command prompt.

Examples

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.

bye

Exits Netsh.exe.

Syntax

bye

Parameters
/?
Displays help at the command prompt.

commit

Commits any changes made in the offline mode to the router. Commit has no effect in online mode.

Syntax

commit

Parameters
/?
Displays help at the command prompt.

delete helper

Removes the helper DLL from netsh.

Syntax

delete helper DLLName

Parameters
DLLName
Required. Specifies the name of the helper DLL that you want to uninstall.

/?
Displays help at the command prompt.

dump

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.

Syntax

dump [FileName]

Parameters
[ FileName]
Specifies the name of the file to which you want to redirect output.

/?
Displays help at the command prompt.

exec

Loads a script file and runs commands from it.

Syntax

exec ScriptFile

Parameters
ScriptFile
Required. Specifies the name of the script that you want to load and run.

Remarks
  • The ScriptFile can run on one or more computers.

exit

Exits Netsh.exe.

Syntax

exit

Parameters
/?
Displays help at the command prompt.

help

Displays help.

Syntax

{/? | ? | help | h}

Parameters
none

offline

Sets the current mode to offline.

Syntax

offline

Parameters
/?
Displays help at the command prompt.

Remarks
  • 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.

online

Sets the current mode to online.

Syntax

online

Parameters
/?
Displays help at the command prompt.

Remarks
  • 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.

popd

Restores a context from the stack.

Syntax

popd

Parameters
/?
Displays help at the command prompt.

Remarks
  • 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.

Examples

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>

pushd

Saves the current context on a first-in-last-out (FILO) stack.

Syntax

pushd

Parameters
/?
Displays help at the command prompt.

Remarks
  • 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.

quit

Exits Netsh.exe.

Syntax

quit

Parameters
/?
Displays help at the command prompt.

set file

Copies the command prompt window output to a file.

Syntax

set file [ mode= ]{openFileName | appendFileName | close}

Parameters
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.

Remarks
  • 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.

Examples

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

set machine

Specifies the computer on which to perform configuration tasks. Used without parameters, the local computer is configured.

Syntax

set machine [ name= ]ComputerName [ user= ][[ DomainName\]UserName ] [ pwd= ][Password | *]

Parameters
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.

Remarks
  • 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.

set mode

Sets the netsh mode to online or offline. Either offline or online must be specified.

Syntax

set mode [ mode= ] {online | offline}

Parameters
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.

show

Displays alias, helper, and mode information.

Syntax

show {alias | helper | mode}

Parameters
alias
Lists all defined aliases.

helper
Lists all top-level helpers.

mode
Displays the current mode.

/?
Displays help at the command prompt.

unalias

Deletes the specified alias.

Syntax

unalias AliasName

Parameters
AliasName
Required. Specifies the name of the alias that you want to delete.

/?
Displays help at the command prompt.

Fanden Sie dies hilfreich?
(1500 verbleibende Zeichen)
Vielen Dank für Ihr Feedback.

Community-Beiträge

HINZUFÜGEN
Microsoft führt eine Onlineumfrage durch, um Ihre Meinung zur MSDN-Website zu erfahren. Wenn Sie sich zur Teilnahme entscheiden, wird Ihnen die Onlineumfrage angezeigt, sobald Sie die MSDN-Website verlassen.

Möchten Sie an der Umfrage teilnehmen?
Anzeigen:
© 2014 Microsoft