Open a command line as Administrator Do a directory listing of the C:\\Windows a
ID: 3637595 • Letter: O
Question
Open a command line as AdministratorDo a directory listing of the C:Windows and C:Program Files directories on your .
Move to the C:Windows directory
Do a directory listing
What would you type to see the directory listing in a page-by-page format?
What would you type to list all the files in the C:Windows directory that started with the letter “s”?
What would you type to list all the files in the C:Windows directory that ended with the ".log" extension?
BONUS:
Create a script which will place in a .csv file c:windows empprocs.csv a listing of processes being run which are taking up more than 10Mb of RAM and the time and date the script was run. Be sure that each time the script is run it appends the information to the file. Show here the contents of that script.
Explanation / Answer
Opening DOS(Windows) If you are using Windows 3.x, there should be an icon in the "Main" folder for MSDOS Prompt. Click on it. Windows 95/98: Start, Programs, MS-DOS Prompt. OR Start, Run, and type "COMMAND" Windows NT/XP/2K: Start, Programs, MS-DOS Prompt. OR Start, Run, and type "CMD" Now, a black window should appear with prompt like this: "C:WINDOWS>". If you are using NT it will only say "C:". It should look like this: If the DOS window fills up the whole screen, type EXIT, then right-click on the MS-DOS Icon, click "Properties" and select the "Screen" tab, click on "Window" instead of "Full-screen", click on "Ok" and then reopen the DOS window. Opening DOS in IBM's OS/2 If you are using the OS/2 platform, follow these instructions for opening a DOS session. 1. Open the "OS/2 System" folder. 2. Open the "Command Prompts" folder. 3. Click on the "DOS Window" icon. Open a command line in NT/2x Go to Start, Run, type "COMMAND". In previous versions this was done by entering CMD. In some versions of NT entering CMD may invoke previous versions of DOS. In some versions of WIN2x, CMD will open a command line with spaces in the directory name, COMMAND will open the window with the old 8 character limit. NT/2x Directory System NT uses user profiles. Each user will have different Desktop and My Documents folders under different names. There is no directory called "Windows", but there is one called "WINNT." Most NT system files will be found in C:WINNTSystem or C:WINNTSystem32. In some cases %SystemRoot% is used to address the system drive regardless of whether it is Windows or WINNT. The different user set-ups are in the C:Documents and settings or C:DOCUME~1. In this directory there will be a different folder for each user who accesses the machine. You may also see Administrator, Default User, All Users and some other funny virtual user folders. Each folder will have its own Desktop, Start Menu, My Documents, Cookies, Favorites and whatever directory structure the user has made beneath. Programs everyone access are usually found in C:program files or C:progra~1(same as Windows). Navigating DOS For those who have never used a command line envornment, it can be a little confusing and frustraiting. But don't worry. It's still confusing and frustraiting for people who have been doing it for years. Start by using the DIR command. DIR At the C:WINDOWS> prompt type DIR for "directory". A list of files should fly up the screen faster than you can read. When the prompt comes up again type DIR/P. This will allow the list to be read one page at a time. Hit enter a few times to get to the end of the list and back to the prompt. DIR is a program that reads scans the current directory and lists all the files. /P is called a switch. The P stands for "page" or "pause"(I can never find out which). When you type DIR/P you are passing /P to the program DIR as a Parameter. You can pass other parameters to DIR. Try typing DIR/W, this puts the file list in "wide" format. Now try this, DIR R*.*. This will display all the files that begin with the letter R. The "*.*" part of the parameter is called a wildcard. A wildcard tells the program that anything after the letter R does not matter. Try this one, DIR *.*EXE. This will display all the files with the .EXE extension. DIR will display all the files, directories, file sizes, time and date or creation. DIR|MORE will show you the list and prompt to continue. Similar to DIR/P. DIR/B for bare or brief, shows only the filenames and their extensions. 8 Character Limits In early systems there was an 8 character limit on file names and directory names. Directory names and file names also could not contain spaces. This scheme still plays a big role in navigating DOS. The standard Windows folder "Program Files" is called "PROGRA~1." The general rule is to count 6 characters in: "PROGRA" then add the ~ and a number. Since we may have multiple files or directories with similar names, we have numbers at the end of the 8 character name. The number is determined by which file or directory was created first. Since Program Files is a built-in directory it gets a 1. If you create a new directory called "Programs" the DOS name will be "PROGRA~2". To view the DOS names, use this command: DIR/X In some Windows versions you can open a DOS prompt in specific directory by first navigating to it through Windows Explorer, then going to Start, Run, CMD or COMMAND. In most cases it will open the default PATH directory. For a full list of DIR possibilities enter DIR/? at the command prompt. Switches In DIR you placed various slashes and letters after the commands. These are "switches" that modify the behavior of a command. Every command has a different set of switches. A "/A" may mean something for a command and something totally different for another. Sometimes a switch may be preceded by a - instead of a /, sometimes there is no special character at all. For each command look at the help file to see the list of valid switches. You may view the help file of any command by typing the command followed by /? or /HELP in older versions. CD Now for a different command. Type in CD.. this should set the prompt to "C:", meaning that you are now in the root directory C:, C:WINDOWS is a sub-directory of C:. CD stands for "Change Directory", a program that allows you to move around the directory structure. The .. parameter you passed to program CD tells the program to move up one directory level. Now pass a different parameter, type CD C:WINDOWSDESKTOP . This will change your directory level to the Desktop folder. Type DIR/P and look at the file listing briefly. Now minimize the DOS window and look at your Windows Desktop. You should see all the same files. Most of the file extensions will be .LNK meaning that they are shortcuts. CD will allow you navigate through the whole directory structure. You may also look at floppy disks: CD A:(sometimes B: also), or CDROMs: CD D:(sometimes E:). CD.. puts you in the parent directory(up one level) CD. refers to the current directory As stated in the DIR section there is an 8 character limit for directory names for many DOS systems. When using CD to move to a directory with a long name be sure to know the DOS name. Example: CD progra~1 to go to "program files" if you are in the root of C:, otherwise use CD C:progra~1 from any other directory. Using drive letters as commands To switch from one drive to another simply type the drive letter. Example: D: or A:. For removable media(floppy, CDROM) you must have the media in the drive to move to it. PATH PATH sets a directory search order. This is useful in many respects. For example, if you are using a boot disk you are running the DOS operating system from that disk and the more complex commands will only run if you specify the location. If you are at the A: prompt and want to run a command on C: you must type FIND C:myfile to use the FIND command, or if you are in C: you would need to type A:FIND C:myfile. To make things easier, type PATH A: at the C: prompt. This way the operating system will know to access A: for all the commands. Some installation programs(especially development environments) will add a line to the AUTOEXEC.BAT like PATH=%PATH%;C:MSSQL7BINN this allows programming bins to be accessed from anywhere on the drive. DOSKEY Type in DOSKEY at the prompt, the DOSKEY program is now loaded. DOSKEY keeps a history of all the commands you type in each session so you can reuse them without typing them in over and over again. You may view your history by hitting the Up-arrow on your keypad. DOSKEY is active in NT by default, but not in Win2K. Consitency is not one of Microsoft's strong points. DEL DEL is the Delete program in DOS. DEL allows you to delete files. For example, typing DEL TEMP.TMP will delete the file temp.tmp. Warning! Using the DEL command in DOS is not like deleting in Windows, there is no Recycle Bin, the files are gone. If you accidentally delete systems files, you are going to have some problems. Only delete files that you are sure about. EDIT At the command prompt type EDIT. The screen should turn blue with a menu bar at the top. This is the DOS EDIT program and it can come in handy. Click on the "File" menu then click "Exit". You should be back at the prompt. With EDIT you can view and alter just about any file on your system, even ones Windows will not allow you to. Warning! Altering system or program files in EDIT can have serious consequences. Make copies of any file you edit and work on the copy so the original remains intact incase you screw up. Believe me, making copies is much easier that reloading your operating system. This time EDIT TEST.TXT this will open the editor and create a text file called "test.txt". Type in some random text. For a moment stop using your mouse. Press and then the Down-arrow on your key pad. This will dropdown the "File" menu. This is how navigation was done before the mouse. Learning how to use the keyboard for navigation can be useful something goes wrong with your computer or your mouse wont work. Save your work and exit the editor. In some early versions of DOS it was called "EDLIN." If EDIT doesn't work try EDLIN instead. RENRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.