THE COMMAND LINE
Internal and External Commands
There are two types of commands that we can run from a command prompt, and they were, 1. Internal commands 2. External commands. Internal Commands Internal commands are nothing but the built-in commands that are shipped along with the operating system, for example, echo, cls, del, dir were few of the well known internal commands. External Commands External commands are the commands that are often created while installing a new application and these commands mostly have no use except calling that application and support files. Few external commands can only be executed in the Run dialog box ((start Run (XP)), (start Programs Accessories Run (Vista)), but not on the command prompt, and those commands include firefox. The firefox command can be executed only from the run line, that too if the firefox application is installed on that machine and it wont work on the command prompt. RUN LINE COMMANDS Commands access.cpl Descriptor Accessibility Controls
accwiz
Accessibility Wizard
appwiz.cpl
Add/Remove Programs
ciadv.msc
Indexing Service
control admintools
Administrative Tools
cleanmgr
Disk Cleanup Utility
control color
Display Properties
compmgmt.msc
Computer Management Console
cliconfg
SQL Client Configuration
certmgr.msc
Certificate Manager
charmap
Character Map
chkdsk
Check Disk Utility
clipbrd
Clipboard Viewer
calc
Opens calculator
cmd
Opens command prompt
devmgmt.msc
Device Manager
dfrg.msc
Disk Defragmenter
diskmgmt.msc
Disk Management
dcomcnfg
Component Services
ddeshare
DDE Shares
diskpart
Disk Partition Manager
desk.cpl
Display Properties
directx.cpl
Direct X Control Panel
dxdiag
Direct X Troubleshooter
drwtsn32
Dr. Watson
eudcedit
Private Character Editor
eventvwr.msc
Event Viewer ( Maintaining System Logs )
explorer
Opens My Documents
freecell
FreeCell Game
fsquirt
Bluetooth Transfer Wizard
fsmgmt.msc
Shared Folders
gpedit.msc
Group Policy Editor
hdwwiz.cpl
Add Hardware Wizard
iexpress
Iexpress Wizard (Package creator)
iexplore
Internet Explorer
inetcpl.cpl
Internet Explorer Properties
ipconfig
Windows IP Configuration
intl.cpl
Regional Settings
joy.cpl
Game Controllers
lusrmgr.msc
Local Users and Groups
logoff
Logs out current user
magnify
Open Magnifier
makecab
Cabinet Maker, file compressor.
msconfig
Open System Configuration Utility
mshearts
Opens Hearts game
msinfo32
System Information
mspaint
Opens Mspaint
msmsgs
Windows Messenger
mstsc
Remote Desktop
mmsys.cpl
Sounds and Audio
mqbkup
Message Queue Backup\Restore Utility
notepad
Opens a New Notepad
ntmsmgr.msc
Removable Storage
ntmsoprq.msc
Removable Storage Operator Requests
ncpa.cpl
Network Connections
netsetup.cpl
Network Setup Wizard
openfiles
Used to view Files Opened Remotely via local
odbccp32.cpl
ODBC Data Source Administrator
osk
On Screen Keyboard
proxycfg
Proxy configuration
packager
Object Packager
perfmon.msc
Performance Monitor
powercfg.cpl
Power Options
qappsrv qwinsta
Displays the available application terminal servers on the network. Display information about Terminal Sessions
rcp recover
Copies files to and from computer running the RCP service Recovers readable information from a bad or defective disk.
relog
Used for Logging.
replace
Replaces files
rexec
Runs commands on remote hosts running the REXEC service
route
Manipulates network routing tables
rsh rsm
Runs commands on remote hosts running the RSH service Manages media resources using Removable
Storage runas Allows a user to run specific tools and programs with different permissions than the users current logon provides.
regedit
Opens Registry Editor
rsop.msc
Resultant Set of Policy
rwinsta
Reset the session
rasphone
Remote Access Phonebook
services.msc
Used for Managing all the services on the computer.
sigverif
File Signature Verification Tool
secpol.msc
Local Security Settings
shutdown
Shutdown Windows
syskey
Windows System Security Tool
sc
Communicates with the service controller and installed services.
schtasks
Replaced with at.
setver shadow
Sets the version number that MS-DOS reports to a program Helps in remote connection & network used to monitor another Terminal Services session
shrpubw
Shared Folder Wizard
sndvol32
Volume Control
sysedit sol
Windows.ini, system.ini, config.sys, autoexec.bat Opens up Solitaire Game
timedate.cpl
Date and Time Properties
telephon.cpl
Phone and Modem Options
telnet
Telnet Client
tftp
Transfers files to and from a remote computer running the TFTP service
tlntadmn
Telnet Administration. Used to start, stop, and send msg to a terminal session connected to via telnet.
tscon
Attaches a user session to a terminal session.
tsdiscon
Disconnects a session from a terminal server.
tskill tourstart
Ends a process. Even can terminate a process running on a remote session. Windows XP Tour Wizard
tsshutdn
shutdown in 60 sec
typeperf
Very useful in login events. Used to monitor Processor threads and writes into a specified log file.
userinit
My Documents
verifier
Driver Verifier Utility
winchat
Microsoft Chat
winmine
Minesweeper Game
wuaucpl.cpl
Automatic Updates
wscui.cpl
Security Center
wmplayer
Windows Media Player
wmimgmt.msc
Windows Management Infrastructure
w32tm
Tool used to diagnose problems occurring with
Windows Time. register to run as a service and add default configuration to the registry
winmsd
System Information.
wupdmgr
Windows Update Launches
winver
Displays Windows Version
write
Opens WordPad
COMMANDS Here I am going to explain few basic and often used commands used for constructing a simple batch program. Before getting into the commands, there are few thing that I need to explain in detail, and they were sub-commands, switches and parameters. Sub-commands: Sub-commands are nothing but the supportive commands that are used along with the main commands to narrow down the result that we are looking for. For example, I want to view how many user accounts are there created in my computer, and this can be done using the net command, as below, As you can see in the above screenshot, net is the main command, where as user is the sub-command used for narrowing down the result that we want. A main command can have any number of subcommands and that too depends upon the usage. Once the command gets executed, its displaying all the available user accounts in my computer.
Switches: Say, for instance I am going to create a new user account in my computer by making use of the net command, and the user account that I wish to create is technocrawl with password P4$ $w0rd and this can be done using the following command,
As you can see in the above screenshot, switch is used again to narrow down the operation of the command that being performed, and most often switches are prefixed with as backward slash / or with an hyphen -. The above command have created a new user account named technocrawl with the password P4$$w0rd. Parameters: Parameters can also be referred as command line arguments and are nothing but the input Supplied to the program by the user while the program is running and depending upon the parameter the program will proceed the further operation. Copy the below given code into a notepad and save it as welcome.bat. Goto command prompt and run the program by using its name welcome.bat (Make sure that the welcome.bat exists in the directory where you want to run). @echo off cd\ echo Welcome %1% pause Output:
Where, welcome is the batch file name and its followed by the parameter, here the parameter is Cybercrawler. Note: You can specify n number of parameters for a batch file. Each parameter can be accessed by using the %number% format, where you have to replace the number with 1 to access the first parameter value, and 2 for accessing the second parameter value and vice-versa. Incase if I want to access the file name then it can be access by using %0%, and for accessing the fifth parameters %5% and so on.
Help is the command that is used to display the available internal commands supported by windows, so that you can type help to know the internal commands available on your computer. Each command has its own sub-commands and switches, and to find out the usage of each command in detail, then you may use the /? (without quotes) followed by the command, for example, if I want to know what are the available sub-commands and switches for the net command, then I can use the net /? command to get more details. Rem: The rem command is used for commenting the source code, so whatever that follows the rem was ignored. The rem command is often used for commenting large batch programs for easy identification incase of updating of modifications. @echo off Rem Program for printing hello world. Echo Hello World. Pause In the above example, the rem command is used for commenting the purpose of the program, but its not necessary for this too simple code. Echo: As said earlier echo command is just like printf statement in C programming, this is used to display the text that follows the command on the output screen. Echo command when used alone will display the state, whether its turned ON or OFF. By default the echo is turned ON, but its always recommended for batch programmers to turn OFF the echo, so that it wont display the prompts like (C:\>) and so on. You can turn OFF the echo command by using the command echo off, and to turn it ON, you can replace the OFF with ON in the above command.
Color: The color command is used to set the foreground and background color of the command prompt. Syntax: Color background_color_code Foreground_color_code
Where, The background_color_code and Foreground_color_code are nothing but the hexadecimal color codes. You can pick the color from the command prompt by typing color /? If I want to change my command prompt color with black as background and green as foreground, then I can use the following command, C:\>color a C:\>color 0a Title: The title command is used to set the title of the command prompt. By default the title of the command prompt is set to C:\Windows\System32\Cmd.exe incase of windows XP and Command Prompt in case of Windows Vista.
Now I wish to change the title to Dave Shell Console, and this can be done by using the command given below,
Prompt: The prompt command is used to change the prompt; the default prompt will be the location of the current directory. You can change the prompt as per your wish by using this prompt command. Type prompt /? for the special codes available for the prompt command.
Cls: The cls command is used for wiping off the text on the command prompt. Date: The date command is used for displaying the current date and also for changing the date. When the date command is executed alone, then it will prompt you to change the date and when it is executed with the /T switch then it will display you the current date. Time: The time command is used for displaying the current time and also for changing the time. When the time command is executed alone, then it will prompt you to change the date and when it is executed with the /T switch then it will display you the current time.