Professional Windows Server 1002003 Security A Technical Reference [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Professional Windows Server 1002003 Security A Technical Reference [Electronic resources] - نسخه متنی

Roberta Bragg

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید









cmd

Runs a new
instance of the command-line shell.

Syntax


cmd [/a | /u] [/q] [/d] [/e:on | /e:off] [/f:on | /f:off] [/v:on | 
/v:off] [ [/s] [/t:bf] [/c | /k] command]

Options


None



Opens a new command shell.


command



Runs the specified command in the current command shell.


/c



Executes command and then exits the shell. (The remainder of the
command following the /c switch is processed as a
command line.)


/k



Executes command and continues running the shell. (The remainder of
the command following the /k switch is processed
as a command line.)


/s



If the first character after /c or
/k is a quote and the /s switch
is used, strips the leading and final closing quotes and retains any
other quotes in the line as part of the command.


/q



Disables local echo.


/d



Disables running AutoRun commands, which are stored in the registry
and executed by default whenever cmd is run. The
registry locations are:

HKLM\Software\Microsoft\Command Processor\AutoRun
HKCU\Software\Microsoft\Command Processor\AutoRun

/a



Sets output to ANSI.


/u



Sets output to Unicode.


/t:bf



Specifies background and foreground colors using hexadecimal numeric
codes of the color command (type color
/?
for a list of codes).


/e:[on | off]



Enables or disables command-shell extensions (enabled by default),
which extend the functionality of the following commands:
del (erase),
color, cd
(chdir), md
(mdir), prompt,
pushd, popd,
set, setlocal,
endlocal, if,
for, call,
shift, goto,
start, assoc, and
ftype.


/f:[on | off]



Enables or disables filename and directory name completion characters
(disabled by default), which use Ctrl-D and Ctrl-F for directory and
filename completion, respectively.


/v:[on | off]



Disables delayed environment-variable expansion (disabled by
default). If enabled, you can use the exclamation character
(!) to substitute the value of environment
variables at runtime.



Examples


Turn autocompletion on:

cmd /f:on

Change to the

C:\Program

Files directory using autocompletion:

cd p

Then press Ctrl-D several times until "Program
Files" appears, and then press Enter.

Discussion


Because understanding cmd is essential to running
all other commands in this chapter, it's worth
taking a deeper look at how it works.

Opening a Command Shell


To launch the command interpreter from the GUI:

Start All Programs Accessories Command Prompt

Start Run cmd OK

To start a new instance of the command interpreter from an existing
instance:

Command interpreter cmd (opens a nested command shell in the same window)

Command interpreter start cmd (opens a new command shell)

Tip: to quit a nested shell, type exit.

Configuring a Command Shell


To configure
the properties of a command prompt
window, right-click on the titlebar of the window and select
Properties. This opens a properties sheet with four tabs. The key
settings here are:

Options



Switches the command interpreter between full screen and a window
(you can switch between them using Alt-Enter), enables QuickEdit
(which lets you cut and paste using a mouse instead of the tedious
Edit menu), enables Insert mode (which lets you insert text at the
present cursor position instead of overwriting previous text there),
and configures the number of commands that can be remembered in the
command-history buffer (you access previously typed commands by using
the up and down arrow keys).


Font



Specifies a font size and name for use in the command-interpreter
window.


Layout



Lets you specify the window and buffer size. Window size refers to
the width in characters and height in lines of the
command-interpreter window. Buffer size refers to the virtual size of
the window when you use the horizontal and vertical scrollbars.
It's a nice touch that the default buffer size is
now 300 lines instead of the 25 lines it was in Windows NT.


Colors



Lets you specify colors for the screen text and background and for
pop-up text and background.



When you change the properties of a command-prompt window and click
OK, a dialog box appears asking you whether you want to apply the
properties to the current command-interpreter window only (in which
case the settings vanish when you close this window) or to future
windows of the same title or started from the same shortcut (in which
case the changes you made are persistent). If you want your settings
to be persistent, you can avoid this annoyance by selecting Defaults
instead of Properties when you right-click on the titlebar of the
command-prompt window.

Running Multiple Commands


You can use conditional
processing symbols to run multiple commands as a single command, with
a command to the right of a conditional processing symbol processing
the results of the command to the left of the symbol. Table 5-2 lists the conditional processing symbols that
are available.

Table 5-2. Conditional processing symbols

Symbol


Syntax


Comment


& [...]


Command1 & Command2


Runs the first command, then the second.


&& [...]


Command1 && Command2


Runs the second command only if the first completed successfully.


|| [...]


Command1 || Command2


Runs the second command only if the first command failed.


( ) [...]


(Command1 & Command2)


Group commands together.


;

or ,


Command1 Parm1;Parm2


Separates command parameters.

Environment Variables


An environment variable is a string that contains
information used to control some aspect of the operating system or
application, such as the path to an important system file or
directory, the number and type of processors on the motherboard, and
so on. The two types of environment variables are:

System variables



These are the same for all users who log on to
the computer, and their effect applies to the whole operating system.
Only members of the Administrators group can create or modify system
variables, and some default ones can't be modified
at all.


Local variables



These differ
for each user who logs on to the computer, and users can create and
modify their own user variables and assign them values. Local
variables were formerly called user variables in W2K and earlier.



Table 5-3 lists the system environment variables
defined in WS2003 together with their default values, while Table 5-4 does the same for local environment variables.

Table 5-3. System environment variables and their default values

Variable


Description


Default value


%CMDEXTVERSION%


Version number of current command processor extensions


2


%COMPUTERNAME%


Name of computer



%COMSPEC%


Exact path to

cmd.exe


C:\Windows\system32

\cmd.exe


%DATE%


Current date (see date)



%ERRORLEVEL%


Error code of most recently executed command (nonzero value indicates
error)



%HOMEDRIVE%


Drive letter connected to user's home directory



%HOMEPATH%


Full path of user's home directory



%HOMESHARE%


Network path to user's shared home directory



%NUMBER_OF_ PROCESSORS%


Number of processors in computer



%OS%


Operating system name


Windows_NT


%PATH%


Search path for executable files


C:\Windows\system32;

C:\Windows;

C:\Windows\system32

\Wbem


%PATHEXT%


List of the file extensions considered executable


.COM;.EXE;.BAT;.CMD;

.VBS;.VBE;.JS;.JSE;.

WSF;.WSH;.VBS


%PROCESSOR_

ARCHITECTURE%


Chip architecture of the processor



%PROCESSOR_

IDENTFIER%


Description of the processor



%PROCESSOR_

LEVEL%


Model number of the processor installed on the computer



%PROCESSOR_

REVISION%


Revision number of the processor



%RANDOM%


Random decimal number between 0 and 32767



%SYSTEMDRIVE%


System root drive


C:


%SYSTEMROOT%


Location of OS root directory


C:\Windows


%TIME%


Current time (see time)



%WINDIR%


Location of OS directory


C:\Windows

Table 5-4. Local environment variables and their default values

Variable


Description


Default value


%ALLUSERSPROFILE%


Location of all users profile


C:\Documents and Settings

\All Users


%APPDATA%


Default location where applications store data


C:\Documents and Settings

\current_user

\Application Data


%CD%


Current directory string



%CMDCMDLINE%


Exact command used to start current command shell



%LOGONSERVER%


Name of domain controller that validated current logon session



%PROMPT%


Command prompt settings for current command shell



%TEMP% and %TMP%


Default temporary directories used by applications for currently
logged-on user


C:\Documents and Settings

\current_user

\Local Settings

\Temp


%USERDOMAIN%


Name of domain containing currently logged-on user's
account



%USERNAME%


Name of currently logged-on user



%USERPROFILE%


Location of profile for currently logged-on user


Working with Environment Variables



To set (create, delete, or modify) environment variables using the
GUI:

Control Panel System Advanced Environment Variables {New | Edit | Delete}

To set a variable from the command line, use the
set command (see set later in
this chapter).

Only a member of the Administrators group can add, delete, or set the
value of a system environment variable. Changes made by the currently
logged-on user affect the user environment variables only for that
user. You may have to reboot your system or close and reopen your
application for the new value of an environment variable to take
effect.

System variables may be used to define paths for logon scripts, home
directories, and user profiles. They may also be used within logon
scripts or in commands executed at the command prompt. To use an
environment variable, enclose it in percent signs. For example,
typing the command:

C:\> cd %windir%

produces the following result:

C:\Windows>

You can easily display the value of an environment variable from the
command line. For example, to display the name of the installed
operating system using the OS system variable, just type:

C:\>echo %os%

which produces the result:

Windows_NT

Who says WS2003 isn't really just Windows NT
disguised?

Notes


  • Use double quotes to enclose commands that contain spaces.

  • Use && to separate multiple commands
    surrounded by quotes in a single command line.

  • Note that /x is the same as
    /e:on and /y is the same as
    /e:off for backward compatibility with the Windows
    NT command shell.

  • Installing new operating-system components or applications may create
    additional environment variables or modify existing ones such as
    PATH.


See Also


runas, set


/ 415