.bat vs .cmd

J

jda

Hi
Is there someone who can tell me the actual difference between files with
..bat and .cmd extensions other than .cmd will not run under win9x systems.
I have tried microsoft.com and a lot of googleling but have not yet found
an answer other than being recommended to use .cmd when scripting for XP
 
S

Shenan Stanley

jda said:
Is there someone who can tell me the actual difference between
files with .bat and .cmd extensions other than .cmd will not run
under win9x systems. I have tried microsoft.com and a lot of
googleling but have not yet found an answer other than being
recommended to use .cmd when scripting for XP

Just a file extension. Both are the same in Windows XP.

..bat == .cmd, according to the REGISTRY (wow, looked far for that one...)

..cmd is just "NT command line program" or something, while .bat is a "batch
script" (it's just a name, they both do exactly the same.)

Why use one over the other? Consistency with the features of the OS or
compatibility with older OSes.
 
D

Dave Patrick

Mostly backward compatibility but see this discussion for some detailed
differences.

http://groups.google.com/group/micr...bject:&+insubject:.bat+insubject:files&hl=en&

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

:
| Hi
| Is there someone who can tell me the actual difference between files with
| .bat and .cmd extensions other than .cmd will not run under win9x systems.
| I have tried microsoft.com and a lot of googleling but have not yet found
| an answer other than being recommended to use .cmd when scripting for XP
| --
| Jakob
 
D

David H. Lipman

From: "Shenan Stanley" <[email protected]>


< snip >

|
| Why use one over the other? Consistency with the features of the OS or
| compatibility with older OSes.
|
| --
| Shenan Stanley
| MS-MVP

Use .BAT to be backward compaible with Win9x/ME. Do not use NT dependent constructs.

Use .CMD to show it uses the more advanced constructs introduced in the NT Based OS command
interpreter.
 
J

jda

Just a file extension. Both are the same in Windows XP.

.bat == .cmd, according to the REGISTRY (wow, looked far for that one...)

.cmd is just "NT command line program" or something, while .bat is a "batch
script" (it's just a name, they both do exactly the same.)

Why use one over the other? Consistency with the features of the OS or
compatibility with older OSes.

Thanks. Sometimes the answer is closer than you think. Although I cannot
find a key like like that one, I can see that they have the same
PersistentHandler. One can just wonder where all the recomendations to use
..cmd comes from
 
P

Pegasus \(MVP\)

jda said:
Hi
Is there someone who can tell me the actual difference between files with
.bat and .cmd extensions other than .cmd will not run under win9x systems.
I have tried microsoft.com and a lot of googleling but have not yet found
an answer other than being recommended to use .cmd when scripting for XP

Further to what the other respondents wrote: When
you use commands that are available in WinNT/2000/XP
only then you could place them into a .cmd file to prevent
the file from being run on a Win9x PC. However, since
Win9x is almost dead, few people bother.
 
D

Dave Patrick

You're welcome.

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

:
| Thanks. I'm glad that it was not only me that had trouble finding a
pattern
| :¤)
| --
| Jakob
 
F

Frankster

I would *assume* (I know what they say! Hehe...) that running a .bat file
envokes the "command" processor and running a .cmd file envokes the "cmd"
processor? If so...

open a command prompt session using Start | Programs | Accessories | Command
prompt. (i.e. cmd.exe)

Type path <enter> look at the path.

Type command <enter>

Type path <enter> look at the path.

The paths are different.........

-Frank
 
W

Wesley Vogel

.bat == .cmd, according to the REGISTRY (wow, looked far for that one...)

It took me little time at all with David Candy's ReportClassName.vbs.

---------------------------
Report Class Name
---------------------------
File Extension .cmd
File Class cmdfile
File Description Windows NT Command Script

Files of .cmd will be listed in the File Types dialog box as Windows NT
Command Script.
---------------------------
OK
---------------------------

---------------------------
Report Class Name
---------------------------
File Extension .bat
File Class batfile
File Description MS-DOS Batch File

Files of .bat will be listed in the File Types dialog box as MS-DOS Batch
File.
---------------------------
OK
---------------------------

Retrieve the Class Name for a File Extension
http://www.kellys-korner-xp.com/regs_edits/ReportClassName.vbs

--
Hope this helps. Let us know.

Wes
MS-MVP Windows Shell/User

In
 
D

Dave Patrick

No it does not work that way. By default they both run within what's defined
as %comspec% which should be [pathtofile]\cmd.exe

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

:
|I would *assume* (I know what they say! Hehe...) that running a .bat file
| envokes the "command" processor and running a .cmd file envokes the "cmd"
| processor? If so...
|
| open a command prompt session using Start | Programs | Accessories |
Command
| prompt. (i.e. cmd.exe)
|
| Type path <enter> look at the path.
|
| Type command <enter>
|
| Type path <enter> look at the path.
|
| The paths are different.........
|
| -Frank
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top