Some commands and utilities help you create a better
working environment at the command prompt. In many cases, these commands
are aesthetic; they don't do any useful work in the sense of modifying a
file or the system state. The following sections describe these
efficiency commands and utilities.
Creating a Nice Work Environment
You might wonder why you
would spend time learning about commands and utilities that don't do any
useful work. For me, it's the same reason for having carpeting on the
floor or a remote for the television; it's all about comfort. For
example, you'll find that the display buffer eventually becomes full of
extraneous data you don't really want to see any longer. Sure, you could
ignore the garbage on your screen, but it's a lot better to get rid of
it so you can work in comfort. Using the CLS command clears the display buffer for you so you can continue working efficiently.
Users of your batch file
and script applications want a nice working environment too. You'll
often use these commands and utilities in your batch files to provide
special effects. The CLS command clears the display so the user viewing the output of the batch file doesn't become confused.
|
1. Redirecting Command Line Output to the Clipboard with the Clip Utility
Anyone who has used
redirection knows the benefits of sending output data to another
location, such as a file, or getting input from another location, such
as the COM port. The Clip utility lets you perform redirection using the
Windows Clipboard. You use redirection or the pipe command as you
normally do. For example, Dir | Clip sends the output for the directory command to the clipboard. This command uses the following syntax:
Clip
You don't need to supply any command line switches when using this command. It works much like the More command. For example, if you want to place the output of the Dir command on the clipboard, you would type Dir | Clip and press Enter. At this point, you can type Notepad and press Enter to start the Notepad utility. Select Edit Paste and you'll see the output of the Dir command in Notepad, where you can edit the information to suit your needs.
2. Clearing the Display with the CLS Command
The Clear Screen (CLS)
command clears the screen buffer and presents you with a clean display.
All that remains is the command prompt. This command uses the following
syntax:
CLS
You don't need to supply any command line switches when using this command.
3. Managing Usernames and Passwords with CmdKey
The CmdKey utility helps
you manage username and passwords. Using this utility, you can display,
create, and delete credentials as needed. However, this utility only
works with the current user. In other words, the credentials you manage
are for the current user, not for another user on the same system. To
work with other users, you must first log in as that user. Consequently,
this command works well with login batch files that perform tasks on
the user's behalf, but not necessarily as a good tool for administering
users at the command line.
A system can have two
kinds of passwords managed by CmdKey. The first is generic passwords
that you can use anywhere. For example, you might create a username and
password to access a remote system using a Virtual Private Network
(VPN). The second is domain passwords that you use to access a domain
server. These password types appear in the Type field output when you
list credentials for your system.
3.1. Displaying
The /list command
line switch lets you list all of the credentials associated with the
current account. This mode uses the following syntax:
cmdkey /list
cmdkey /list:targetname
The following list describes each of the command line arguments.
/list
Displays all of the entries or only those that you specify with a target name.
targetname
Defines a target
credential. You use the name of the credential as the target. This
command line argument doesn't allow wildcard characters, so you can only
use it to list one credential at a time.
3.2. Creating
Creates a new domain or generic credential based on a username and password. Use the /add command line switch to create domain credentials and the /generic command line switch to create generic credentials. This mode uses the following syntax:
cmdkey /add:targetname /user:username /pass:password
cmdkey /add:targetname /user:username /pass
cmdkey /add:targetname /user:username
cmdkey /add:targetname /smartcard
cmdkey /generic:targetname /user:username /pass:password
cmdkey /generic:targetname /user:username /pass
cmdkey /generic:targetname /user:username
cmdkey /generic:targetname /smartcard
The following list describes each of the command line arguments.
/add
Creates a domain credential.
/generic
Creates a generic credential.
targetname
Defines a target
credential. You use the name of the credential as the target. This
command line argument doesn't allow wildcard characters, so you can only
use it to list one credential at a time.
/user:
usernameSpecifies the username used for login purposes. The username can include any qualifiers required to perform the login.
/pass or /pass:
passwordSpecifies the password used for login purposes. If you specify /pass
without the password, the system prompts you for a password to use on
the remote system. Unlike many password prompts, this prompt doesn't
display the password characters as asterisks (*), so it's easy to make
mistakes. Make sure you type the password carefully.
/smartcard
Creates a password based on the content of a smartcard. The system prompts you to provide the smartcard as part of the input.
3.3. Deleting
You can't change
a credential using the CmdKey utility. To change a credential, you must
first delete the old credential and then create a new one. In addition,
you'll likely find that you need to delete old credentials when you
don't need them any longer. This mode uses the following syntax:
cmdkey /delete:targetname
cmdkey /delete /ras
The following list describes each of the command line arguments.
/delete:
targetnameRemoves the specified credential. You must provide a target name unless you're deleting a Remote Access Server (RAS) credential.
/ras
Specifies that you want to remove a RAS credential.
4. Changing Screen Colors with the Color Command
The Color command
changes the foreground (text) and background colors of the command
window. This command uses the following syntax:
COLOR [FG]
The following describes the command line argument.
FG
Sets the
foreground (F) and background (G) colors. You must place the values
together, without any space between. If you use the Color
command without specifying color values, the command changes the colors
to the default values used when you opened the command window. The
following list tells you which colors you can use at the command prompt,
along with their associated color number.
0—Black
1—Blue
2—Green
3—Aqua
4—Red
5—Purple
6—Yellow
7—White
8—Gray
9—Light blue
A—Light green
B—Light aqua
C—Light red
D—Light purple
E—Light yellow
F—Bright white
5. Working with the System Date Using the Date Command
The Date command displays or sets the system date. This command uses the following syntax:
DATE [{/T | date}]
The following list describes each of the command line arguments.
/T
Displays the date without prompting for a new date. This command line switch only works when you enable command extensions.
date
Specifies the new system date.