Welcome! Log In


La commande la plus connue (si on a pas de connexion au réseau alors qu'on est sûr d'avoir la bonne config IP):

netsh winsock reset

Les commandes suivantes sont disponibles :

Commandes dans ce contexte :
.. - Monte d'un niveau de contexte.
? - Affiche une liste de commandes.
abort - Rejète les changements effectués en mode déconnecté.
add - Ajoute une entrée de configuration à une liste d'entrées.
alias - Ajoute un alias.
bridge - Modifications pour le contexte `netsh bridge'.
bye - Quitte le programme.
commit - Valide les changements effectués en mode déconnecté.
delete - Supprime une entrée de configuration d'une liste d'entrées.
diag - Modifications pour le contexte `netsh diag'.
dump - Affiche un script de configuration.
exec - Exécute un fichier script.
exit - Quitte le programme.
firewall - Modifications pour le contexte `netsh firewall'.
help - Affiche une liste de commandes.
interface - Modifications pour le contexte `netsh interface'.
lan - Modifications pour le contexte `netsh lan'.
nap - Modifications pour le contexte `netsh nap'.
offline - Définit le mode courant comme non connecté.
online - Définit le mode courant comme connecté.
popd - Retire un contexte de la pile.
pushd - Émet le contexte actuel sur la pile.
quit - Quitte le programme.
ras - Modifications pour le contexte `netsh ras'.
routing - Modifications pour le contexte `netsh routing'.
set - Met à jour les paramètres de configuration.
show - Affiche les informations.
unalias - Supprime un alias.
winsock - Modifications pour le contexte `netsh winsock'.

Les sous-contextes suivants sont disponibles :
bridge diag firewall interface lan nap ras routing winsock

Netsh Commands for All Contexts
Updated: February 8, 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:

..

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.

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:

Copy Code
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 helperDLLName

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
execScriptFile

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
unaliasAliasName

Parameters
AliasName
Required. Specifies the name of the alias that you want to delete.
/?
Displays help at the command prompt.



The Netsh Command-Line Utility
Updated: January 21, 2005

Applies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1, Windows Server 2003 with SP2


The Netsh command-line utility
Netsh is a command-line and scripting utility for networking components for local or remote computers. The Netsh utility can also save a configuration script in a text file for archival purposes or for configuring other servers.

The Netsh utility is a shell that can support multiple components through the addition of Netsh helper DLLs. A Netsh helper DLL extends Netsh functionality by providing additional commands to monitor or configure a specific networking component. Each Netsh helper DLL provides a context, a group of commands for a specific networking component. Within each context, subcontexts can exist. For example, within the routing context, the subcontext ip exists to group IP routing commands together.

Netsh command-line options include the following:

-a AliasFile

Specifies that an alias file is used. An alias file contains a list of netsh commands and an aliased version so that you can use the aliased command line in place of the netsh command. You can use alias files to map commands that may be more familiar in other platforms to the appropriate netsh command.


-c Context

Specifies the context of the command that corresponds to an installed helper DLL.


Command

Specifies the netsh command to execute.


-f ScriptFile

Specifies that all of the netsh commands in the ScriptFile file are run.


-r RemoteMachine

Specifies that the netsh commands are run on a remote computer specified by either its name or IP address.


You can abbreviate commands to the shortest unambiguous string. For example, issuing the command sh ip int is equivalent to issuing show ip interface. Netsh commands can be either global or context-specific. Global commands can be issued in any context and are used for general Netsh utility functions. Context-specific commands vary according to the context. You can log commands issued to a log file to create an audit trail of a netsh command session.

The following table lists the netsh global commands.


Command Description
..
Moves up one context level.

? or help
Displays command-line Help.

show version
Displays the current version of Windows and the Netsh utility.

show netdlls
Displays the current version of installed Netsh helper DLLs.

add helper
Add a Netsh helper DLL.

delete helper
Removes a Netsh helper DLL.

show helper
Displays the installed Netsh helper DLLs.

cmd
Creates a command window.

online
Sets the current mode to online.

offline
Sets the current mode to offline.

set mode
Sets the current mode to online or offline.

show mode
Displays the current mode.

flush
Discards any changes in offline mode.

commit
Commits changes made in offline mode.

set audit-logging
Turns on or off the logging facility.

show audit-logging
Displays current audit logging settings.

set loglevel
Sets level of logging information.

show loglevel
Displays the level of logging information.

set machine
Configures the computer on which the netsh commands are executed.

show machine
Displays the computer on which the netsh commands are executed.

exec
Executes a script file containing netsh commands.

quit or bye or exit
Exits the Netsh utility.

add alias
Adds an alias to an existing command.

delete alias
Deletes an alias to an existing command.

show alias
Displays all defined aliases.

dump
Writes configuration to a text file.

popd
A scripting command that pops a context from the stack.

pushd
A scripting command that pushes the current context on the stack.


The Netsh utility has the following command modes:

Online

In online mode, commands issued at a Netsh command prompt are executed immediately.


Offline

In offline mode, commands issued at a Netsh command prompt are accumulated and executed as a batch by issuing the commit global command. You can discard accumulated commands by issuing the flush global command.


Script

With either the -f command-line option or by issuing the exec global command at a Netsh command prompt, all the netsh commands in the specified file are executed.


To create a script of the current configuration, use the global dump command. The dump command outputs the current running configuration in terms of netsh commands. You can use the script created by this command to configure a new server or to reconfigure the existing server. If you are making extensive changes to the configuration of a component, it is recommended that you begin the configuration session with the dump command, in case you need to restore the configuration prior to changes being made.
Sorry, only registered users may post in this forum.

Click here to login