Solved

Need help understanding MS DOS commands

Posted on 2008-10-03
14
687 Views
Last Modified: 2012-05-05
I asked a question in a MS newsgroup, but I still don't understand the answer:   I wanted to print out the list of folders in the Outlook Express message pane, and the following was the recommendation of one way to accomplish it:

(Is a list of the "folders" which actually contain messages good enough?

You could adapt this suggestion I made to someone who wanted
"a list of subscribed newsgroups"...

<paste>
If you only had one news account and you hadn't visited newsgroups
but not subscribed to them you could get a list of your  *.dbx  in your
Message Store subdirectory as a good approximation to a list of your
"subscribed" newsgroups.

E.g. right-click Properties on an Outlook bar item.
Then press Tab to select the filename under the label:
    "This folder is stored in the following file:"
Capture that selection.  (E.g. press Ctrl-c)
Switch to a cmd window and type:   cd  /d
(with a trailing space <g>)
Then right-click, Paste.   Remove the filename (e.g. press Backspace
back to the last backslash (\)  and press Enter.

Then enter:   dir/b/on  *.dbx   >dbx.txt
(or whatever pattern you would like to list just some newsgroup .dbx,
e.g. for  just microsoft.public  ones you could enter:
    dir/b/on  microsoft.public.*.dbx   >mpdbx.txt
etc.)

Note the filter on that line captures the output of the command
into the same directory so it can be browsed and further edited
by Notepad (or printed or whatever else you like with it later.}

My response:

Robert,

I went to the DOS command window and it was pointing to C:\Documents and
Settings\HP_Administrator>.  I cd\ back to the C:\ prompt and then pasted in
the directory for one of  my dbx files in OE as follows:
C:\Documents and Settings\HP_Administrator\Local Settings\Application
Data\Identities\{0997C9F9-D1FA-4A60-90E4-0FF3700CE7B1}\Microsoft\Outlook
Express\Weekend Letter.dbx

I first backspaced over Weekend Letter.dbx and hit Enter

I got the following error message:
"Documents" is not recognized as an internal or external command, operable
program or batch file

Can you tell me what I'm doing wrong?

MVP's response:
Not following instructions?
Specifically, there is no sign that you did this

E.g. you captured the path and switched to a cmd window all right
but then just pasted the path in as if it was a command to be executed
from the drive root?   Note the whole idea is to paste the path as an
_operand_ of a command that you start typing:

    CD  /D

Also, when you do what I suggest you don't need to use quotes around
your operand, even if the path you are pasting contains spaces.
The first space in your pasted path  is what caused the misleading error
message you got.   ; )
-------------------------------------------------------------------------------
I don't know what the cd /D does...., and I don't know where the spaces are. Please write a "for dummies" answer. Thanks in advance.

0
Comment
Question by:sheana11
  • 4
  • 3
  • 3
  • +3
14 Comments
 
LVL 1

Expert Comment

by:hulent
ID: 22634706
Try putting quotation marks around c:\Document and Settings\... such as this:

"C:\Documents and Settings\HP_Administrator\Local Settings\Application
Data\Identities\{0997C9F9-D1FA-4A60-90E4-0FF3700CE7B1}\Microsoft\Outlook
Express\Weekend Letter.dbx"
0
 
LVL 67

Assisted Solution

by:sirbounty
sirbounty earned 100 total points
ID: 22634843
cd /d changes the directory, and volume/drive, if necessary...

cd "\Program Files" will change to C:\Program Files if you're already on C (i.e. at the C:\> prompt).

cd /d "C:\Program Files" will change to that folder, even if you're at the F:\> prompt...
0
 
LVL 11

Expert Comment

by:ladarling
ID: 22634924
Quotation marks wont help...
Here is what is happening:
You want to change the directory of your command prompt to be in the same directory as your outlook folders. The CD /D command means Change Directory and, if necessary Drive (/D) to get to the following folder: <paste your folder here>
Once executed, you will be in the same folder as your outlook folders.
The next command is:
dir/b/on *.dbx >Folders.txt
This command says : List all of the DBX files (Outlook Folders) in this folder in a "/b" bare format (no dates, filesizes, etc), "/on" sorted by name and place those file names in a text document named Folders.txt.
The next command that I would run from the prompt would be:
notepad Folders.txt
This will open your new list of outlook folders so you can deal with them as you wish.
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 11

Accepted Solution

by:
ladarling earned 250 total points
ID: 22635013
Here are the three sequential commands, and the contents of Folders.txt

C:\cd /d C:\Documents and Settings\cscallion\Local Settings\Application Data\Identities\{31391EF3-B3AC-4F12-94D8-DC2DA45E9526}\Microsoft\Outlook Express
C:\Documents and Settings\cscallion\Local Settings\Application Data\Identities\{31391EF3-B3AC-4F12-94D8-DC2DA45E9526}\Microsoft\Outlook Express>dir/b/on *.dbx >Folders.txt
C:\Documents and Settings\cscallion\Local Settings\Application Data\Identities\{31391EF3-B3AC-4F12-94D8-DC2DA45E9526}\Microsoft\Outlook Express>notepad folder.txt

Archive.dbx
BounceBacks.dbx
Calendar.dbx
Conflicts.dbx
Contacts.dbx
Deleted Items.dbx
Drafts.dbx
ExEx.dbx
Folders.dbx
Geneva Messages.dbx
Inbox.dbx
Journal.dbx
Junk E-mail.dbx
Local Failures.dbx
Microsoft at Home.dbx
Microsoft at Work.dbx
Notes.dbx
Offline.dbx
Outbox.dbx
Quarantine.dbx
RSS Feeds.dbx
Sent Items.dbx
Server Failures.dbx
Sync Issues.dbx
Tasks.dbx

Open in new window

0
 
LVL 67

Expert Comment

by:sirbounty
ID: 22635073
To clarify, you will need quotes if the path contains spaces...

C:\Documents and Settings would be recognized as three parameters to any dos command.

CD /D "C:\Documents and Settings" is the correct method to change to that directory...
0
 
LVL 11

Expert Comment

by:ladarling
ID: 22635351
To clarify, you will need quotes if the path contains spaces...
That is incorrect. If you are using Windows 2000/XP/Vista then the command interpreter fully comprehends Windows folder naming conventions, spaces and all.

sshot.png
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 22635413
And that's not entirely accurate either.
Try using any external command against Documents and Settings.
Even some internal commands will fail - for example, try using "DIR" against Documents and Settings without enclosing it in quotes.

It's good practice to enclose all folder names with quotes, then you won't have to guess if it'll work with that command or not...

0
 
LVL 11

Expert Comment

by:ladarling
ID: 22635571
Try using any external command against Documents and Settings.
With all due respect, that is not the problem that the author is facing. S/he needs to CD to the outlook folders directory, which works just as described. If you read the authors post carefully:
I went to the DOS command window and it was pointing to C:\Documents and
Settings\HP_Administrator>.  I cd\ back to the C:\ prompt and then pasted in
the directory for one of  my dbx files in OE as follows:
C:\Documents and Settings\HP_Administrator\Local Settings\Application
Data\Identities\{0997C9F9-D1FA-4A60-90E4-0FF3700CE7B1}\Microsoft\Outlook
Express\Weekend Letter.dbx

I first backspaced over Weekend Letter.dbx and hit Enter

I got the following error message:
"Documents" is not recognized as an internal or external command, operable
program or batch file

Can you tell me what I'm doing wrong?

You can see that the problem is that the path was not prefixed with CD /D. The interpreter tried to execute the path as a command, which of course resulted in the error described.
CD will always work with valid paths, enclosed with quotes or not. The follow-up commands that need to be executed do not involve paths at all, so... in this case... quotes wont help.
0
 
LVL 38

Assisted Solution

by:BillDL
BillDL earned 150 total points
ID: 22644348
sheena11

ladarling's 2nd last paragraph explains exactly what happened, and is your answer.  Please consider my comment here as an extension to that correct answer, and just a helping hand to explain some other useful facts that may help you in the future.

As ladarling explained, you just pasted a directory path at the command prompt, and Windows 2000/XP doesn't know what you are asking it to do with that.  You needed to tell it to "Change Directory" to that path, but neglected to prefix the path with that command.

You already had the "DOS" Prompt showing on screen like this, ie. indicating that you were currently in (or had Changed Directory into)  the "HP_Administrator" folder:

C:\Documents and Settings\HP_Administrator>

The Windows XP CMD window is set to open in the user's profile folder by default.  More about this in a moment.

You then just effectively pasted the full path to the current user "Outlook Express" folder right in front of the Prompt (ie. the >  )

It hasn't got a clue what it is meant to do, and assumes that you have entered a command.  Command line programs or commands are deliberately named as just one word with no spaces, because the name following the space after a command name is interpreted as an additional Option (a "switch") or a Parameter.  A Parameter is just an additional piece added to the command to make it more specific, or to tell the command exactly how to do something.

In this case, Windows CMD sees only up to the first space in your "command", ie. the word "Documents" and is telling you that it does not know of a program or command named "Documents" (as documents.exe, documents.com, documents.bat, or documents.cmd).  Even if there was a program named "Documents.exe", the next word "and" would be treated as a parameter and that most certainly wouldn't be a valid parameter.

For your information, Windows XP stores what are known as Variables.  Open a Command window and type the command   SET

You will see a whole bunch of lines like this (only an extract shown):

ALLUSERSPROFILE=C:\Documents and Settings\All Users
APPDATA=C:\Documents and Settings\HP_Technician\Application Data
CLIENTNAME=Console
CommonProgramFiles=C:\Program Files\Common Files
HOMEDRIVE=C:
HOMEPATH=\Documents and Settings\HP_Technician
TEMP=C:\DOCUME~1\TECHNI~1\LOCALS~1\Temp
TMP=C:\DOCUME~1\TECHNI~1\LOCALS~1\Temp
USERNAME=HP_Technician
USERPROFILE=C:\Documents and Settings\HP_Technician
windir=C:\WINDOWS

The uppercase names in front of the = sign are the variable names, and the text string after the = sign is the value stored against that variable name.

So, if you opened a Command Window and typed the command:

cd %HOMEPATH%

it would change directory to:
C:\Documents and Settings\HP_Technician>

Type the command:

cd %HOMEDRIVE%

and it will change to C:\>

You can see the System Variables and User Variables if you Right-Click on My Computer, choose "Properties" and then click the "Environment Variables" button under the "Advanced" tab.

I personally find it a nuisance that Windows XP always opens a new CMD window in the %HOMEPATH% folder, and you will see why it does this if you RIGHT-Click on the "Command Prompt" shortcut in your Start Menu, choose "Properties", and open the "Shortcut" tab.

The "Target" field will show:   %SystemRoot%\system32\cmd.exe
The "Start In" field will show:  %HOMEDRIVE%%HOMEPATH%

You can easily create a COPY of this shortcut somewhere else, then delete the %HOMEPATH% from that field just leaving it to start in %HOMEDRIVE%, which in your case is C:\   You just "Apply" the change to the Property dialog so that when you open that shortcut it will open to the C:\> Prompt.

SirBounty has given some good advice about always double quoting full paths where there are spaces in the names as a case of good practice.  Windows XP's CMD is pretty good at not needing this MOST of the time, but there are odd occasions where you do need to.  Of course, this has nothing to do with your original "command", which wouldn't have worked without the CD telling it to change directory to what you specified.

As a matter of interest to you, you DO NOT usually have to actually change directory INTO a folder to then list the contents or pass any command that acts on the contents of a folder.  You could just as easily have issued the following command to list all *.dbx files in the folder, regardless of what folder the command window happened to be in at the time:

dir /on /a /b %HOMEPATH%\Local Settings\Application
Data\Identities\{0997C9F9-D1FA-4A60-90E4-0FF3700CE7B1}\Microsoft\Outlook Express\*.dbx

If you had added the following after the *.dbx, you could have redirected the screen output to a named file in the root of the C:\ Drive for easy retrieval:

> %HOMEDRIVE%\DBX_Files.txt

Furthermore, it is possible for you to create a NEW USER VARIABLE that points to your "Outlook Express" folder using the "Environment Variables" dialog I mentioned earlier.  Say, for example, you created a variable named "DBXFOLDER" (without the " ") and set it to the full path to that "Outlook Express" folder (with all the spaces and no " "), you could have issued the command:

dir /on /a /b "%DBXFOLDER%\*.dbx" > "%HOMEDRIVE%\DBX_Files.txt"

I would suggest that you use the enclosing " " in both paths specified.

I hope this helps you understand some things you may not have been aware of, so that it may help you out in future.

If you don't have any more issues, then it would be a good idea to accept an (or maybe share) answer(s) to conclude this question, but DO NOT nclude my comment in any points share as it is just additional info.

Bill
0
 
LVL 38

Expert Comment

by:BillDL
ID: 22644466
Oh yes, there is one other issue that you specifically mentioned, and which has confused you.

The CD command "Changes Directory" to whatever path you tell it to change into.  The command  CHDIR  does the same thing.

The CD \  command just tells CMD to go back to the Root of the drive that you are currently on, in your case to C:\

There are other symbols you can use.  A double-dot    CD ..   will go UP one level.  So, having opened to the prompt:

C:\Documents and Settings\HP_Administrator>

if you were to issue the command   cd  ..

it would take you BACK UP to:

C:\Documents and Settings>

To go FORWARDS, ie, DOWN through the folders and sub-folders, you then need to specify a path to that folder.

Let's assume that you want to go from there downwards into the "HP_Administrator" folder and then into the sub-folder of that "Local Settings", you could type the command:

cd HP_Administrator\Local Settings

to end up here:

C:\Documents and Settings\HP_Administrator\Local Settings>

It is also possible to go Backwards (up) and then Forwards (down) in one command.  Let's assume that you want to back-pedal from the above prompt to get to the
C:\Documents and Settings\All Users
folder.  That's Back (Up) two steps and then Forward (Down) one.

The following command would change directory into it:

cd ..\..\All Users

Similarly, if you wanted to go all the way back up to the root and then forwards to the "Windows" folder, you could use this command from wherever you are:

cd \Windows

That's a whole lot easier than (assuming you are currently in the HP_Administrator\Local Settings folder):

cd ..\..\..\Windows

When you are dealing with different Drive Letters, Windows XP differs from Old "DOS" as found in Win98.  To change to a different DRIVE in OLD DOS, you DO NOT use the Change Directory command, because the different drive letter is not a "Directory".  To change to a different drive, you had to issue the command (assuming you were changing to the D:\ Drive):

D:

Windows XP's command line allows you to change "directory" to a different DRIVE, and additionally also specify a Folder to go to on that drive.  That's what sirbounty was saying earlier when he gave the CD /P switch.

If you are in the C:\Documents and Settings\HP_Technician> folder in a command window and you want to move into the following folder on a 2nd hard drive:

D:\My Stuff\Pictures

the following command will take you there:

cd /d "D:\My Stuff\Pictures"

If you leave out the /D switch, it will remember that you have decided to change directory on the D: Drive to the \My Stuff\Pictures folder, but it will NOT take you there.  The /D is needed to actually do the change.

Something to be aware of, when talking about how the Windows XP CMD remembers what directory on another drive you told it to change to, is that if you just change drives, then it will go to the folder on that drive that you previously specified.  Here's what I mean, and is taken from the above hypothetical folders on a 2nd hard drive with the letter D:

While in the folder: C:\Documents and Settings\HP_Technician>
you type the CD command intending that it MOVES  to the "D:\My Stuff\Pictures" folder, but you forget the /D switch, ie. the command:

cd "D:\My Stuff\Pictures"

You will see immediately underneath the prompt you were at, that it acknowledged the CD command, but it just came right back to the:
C:\Documents and Settings\HP_Technician>
prompt again.

If you now type the command:

D:

it will take you right into the "D:\My Stuff\Pictures" folder, because it has remembered that you made that the "Current Directory" on that drive, but elected (accidentally) to physically go there.  The corect method of just changing drives, but NOT going to any folders on it, would have been:

cd /d D:\

The same is true when changing BACK to the drive you were on before, and you may find that you are back in the folder you were in.  Sometimes this is useful, but sometimes it is a pain.

Hopefully this sheds some light on what seems to be mysterious but is really quite simple if you just imagine a Windows Explorer folder tree while typing commands.

You may find the following Windows XP powertoy useful.  It adds a new Right-Click option "Command Window Here" for most folders.  Some System folders don't show the option.  The command window will open changed into that directory.

Open Command Window Here:
http://download.microsoft.com/download/whistler/Install/2/WXP/EN-US/CmdHerePowertoySetup.exe
0
 

Author Comment

by:sheana11
ID: 22699552
Will give feedback after holiday weekend...am working all 3 days!
0
 
LVL 16

Expert Comment

by:t0t0
ID: 22720946
For what it's worth...

I agree you can access the files in folders (directories in DOS) by CD-ing into the folder first however, it can be tedious having to type those long filenames.

Has anyone considered the use of SUBST ?

Suppose you CD into say "C:\Windows\Downloaded Program Files" frequently, or you want to get to it quickly, then you can assign the target folder a drive letter such as:

SUBST J: "C:\Windows\Downloaded Program Files"

Now you can simply change into the folder as you would to another drive such as:

J:

And you're there!!

Change back to C:

C:

And you're back again.... Now back to J: again:

J:

You can now do a DIR or whatever grabs your fancy.



Also, suppose you're currently at C:\Temp, you could copy all the files from the current folder to the SUBST'd folder just as you would a normal drive ie:

COPY *.* J:



Finally, when you drop back into windows and fire up explorer, you'll notice a new drive appear named Local Disk (J):

Wow!! You say. Where did that come from?....

Hehehe....

Oh, to remove the SUBST assignment, enter the following:

SUBST /D J:

Simple eh! Good old DOS....



There are loads of applications for SUBST...

How about SUBSTing a folder with a long filename and then being able to access it using 16-bit prorams' FileOpen dialog boxes.
0
 

Author Comment

by:sheana11
ID: 23105882
Fantastic work, guys, not enough points to go around. Thanks so very much!
0
 
LVL 38

Expert Comment

by:BillDL
ID: 23107216
Thank you Sheana
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question