IT tutorials
 
Windows
 

Windows Server 2008 : Basic Rules When Using the Command Prompt - Understanding Paths, Using Basic Commands, Redirecting Output to Files

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
6/7/2013 7:27:30 PM

1. Understanding Paths

The command prompt shows the current path at the prompt. For example, if you open a prompt with administrator privileges, you’ll see the following prompt:

c:\Windows\system32>

When executing a command, the system always looks in the current location for the file or executable command. For example, if you have a file named 70-642.txt in the current path, you can use the following command to open it with Notepad:

C:\studynotes>notepad 70-642.txt

You can also specify a path with the command. For example, if your file is in a folder named studynotes on the c: drive, you can use the following command:

C:\>notepad c:\studynotes\70-642.txt

In the second example that includes the path, it doesn’t matter what your current path is because you specified it in the command.

You might notice that the command is notepad, but the path to notepad is not needed when it is executed. Notepad is located in the c:\windows folder and Windows Server 2008 is already aware of this path. Windows Server 2008 is aware of the following paths by default:

  • c:\windows

  • c:\windows\system32

  • c:\windows\wystem32\wbem

Tip

Windows Server 2008 R2 is also aware of the path to PowerShell by default (c:\windows\system32\windowspowershell\v1.0\). Windows Server 2008 (not R2) adds this path when PowerShell is installed.


You can view the path with the commands shown in the following table.

CommandComments
c:\>echo %path%

The output is c:\Windows\system32;c:\Windows;c:\Windows\System32\Wbem;c:\Windows\System32\WindowsPowerShell\v1.0\
c:\>path

The output is PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\

You can also modify the path with the commands in the following table.

CommandComments
c:\>path = c:\mypath

Sets the path for the current command prompt session to only c:\mypath. When you close the session and open another session, the path reverts to the value in the %path% variable.
c:\>path = %path%;c:\mypath

Appends the current path with the value you include (in the example, c:\mypath). When you close the session and open another session, the path reverts to the value in the %path% variable.

2. Using Basic Commands

The following table shows many of the basic commands used at the command prompt.

Note

The term directories was used in the original DOS commands, and Windows uses the term folders. However, directories and folders refer to the same thing. In other words, directories and folders are synonymous.


CommandComments
dir
c:\>dir
c:\>dir *.txt
c:\>dir appcmd*.* /s

Retrieves a listing of the current folder.

Wildcards can be used. The example displays all files with a .txt extension.

The /s switch looks in subdirectories also. The example lists all instances of the appcmd file on the c: drive.
cd
c:\>cd data\study
c:\data\study>cd ..
c:\data\>cd \
c:\>

Changes directory.

The cd .. command moves up one folder.

The cd \ command moves to the root of the current drive.
md
c:\>md tmpdata

Makes a directory.
rd
c:\>rd tmpdata
c:\>rd tmpdata /s
c:\>rd tmpdata /s /q

Removes a directory if it is empty.

The first example removes the folder named tmpdata, but only if it is empty.

The next example (with /s for subfolders) removes the folder and any subfolders even if there is data in any of the folders.

The last example (with /q for quite mode) suppresses the confirmation prompt.
exit
c:\>exit

Ends the current command prompt session and closes the command prompt window.

3. Redirecting Output to Files

Many times you’ll want the output of a command sent to a file. You can do this with the redirector symbol (>), as shown in the following table.

RedirectorDescription
>
Command > filename
c:\>gpresult /z > grouppolicies.txt

Sends output to a file. The file is created if it doesn’t exist and overwritten if it exists.
>>
Command >> filename
c:\>gpresult /z >> grouppolicies.txt

Appends output to a file. Existing data is not overwritten.


 
Others
 
- Windows Server 2008 : Basic Rules When Using the Command Prompt - Understanding Wildcards, Getting Help
- Windows Small Business Server 2011 : Windows Storage Server 2008 R2 Essentials (part 2) - Connecting to Windows Storage Server 2008 R2 Essentials
- Windows Small Business Server 2011 : Windows Storage Server 2008 R2 Essentials (part 1) - Connecting Windows Storage Server Essentials to the SBS Domain
- Windows Small Business Server 2011 : Using the Command Line to Manage Backups
- Windows 8 : Security - Securing Internet Explorer
- Windows 8 : Security - Encrypting File System
- Windows 8 : Security - BitLocker Drive Encryption
- Windows Vista : Deployment Platform - Basic Deployment Process, BDD 2007 Deployment Process
- Windows Vista : Platform Components (part 2) - Windows Setup, Sysprep, Windows PE, Windows DS, ImageX
- Windows Vista : Platform Components (part 1) - Windows Imaging, Answer Files, Windows SIM
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us