Command Line Programs: Difference between revisions

From ITCwiki
Jump to navigation Jump to search
No edit summary
Line 18: Line 18:




== '''commands''' ==
=== '''commands''' ===





Revision as of 19:25, 26 July 2010

Command line Programs and Functions



NetSH

Network shell netsh is a command-line utility that allows you to configure and display the status of various network communications server roles and components after they are installed on computers running Windows Server 2008 R2 and Windows Server 2008

Some client technologies, such as Network Access Protection (NAP) client and Dynamic Host Configuration Protocol (DHCP) client, also provide netsh commands that allow you to configure client computers running Windows® 7 and Windows Vista®.

In most cases, netsh commands provide the same functionality that is available when using the Microsoft Management Console (MMC) snap-in for each server role or component. For example, you can configure Network Policy Server (NPS) by using either the NPS MMC snap-in or the netsh commands in the netsh nps context.

In addition, there are netsh commands for network technologies, such as for IPv6, network bridge, and remote procedure call (RPC), that are not available in Windows as an MMC snap-in


commands

..

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



Syntex

..


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 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, netshoverwrites 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 useset 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.



DNScnt