PC Review


Reply
Thread Tools Rate Thread

.cmd vs. .bat

 
 
John Goche
Guest
Posts: n/a
 
      28th Nov 2006

Hello,

Is there a difference between .cmd files and .bat files?
More precisely, is there an established convention as
to when to name a file containing a set of commands
with the .cmd extension as opposed to with the .bat
extension?

Thanks,

JG

 
Reply With Quote
 
 
 
 
Pop`
Guest
Posts: n/a
 
      28th Nov 2006
John Goche wrote:
> Hello,
>
> Is there a difference between .cmd files and .bat files?
> More precisely, is there an established convention as
> to when to name a file containing a set of commands
> with the .cmd extension as opposed to with the .bat
> extension?
>
> Thanks,
>
> JG


No, there is no difference. .CMD is normally used in XP and beyond, plus
they kept the .BAT compatability for older scripts. They're all considered
script files.

The only difference is in the sequence in which files are searched for
execution. If you have say a 1.cmd and a 1.bat file inthe same folder and
it's in the path and you execute them by just typing "1", the cmd fill will
run. If no cmd files are found, then the bat file will run. Etc.

HTH
Pop`


 
Reply With Quote
 
Ken Blake, MVP
Guest
Posts: n/a
 
      28th Nov 2006
Pop` wrote:

> The only difference is in the sequence in which files are searched for
> execution. If you have say a 1.cmd and a 1.bat file inthe same
> folder and it's in the path and you execute them by just typing "1",
> the cmd fill will run.



It's the other way around. The 1.bat file will run.

--
Ken Blake - Microsoft MVP Windows: Shell/User
Please reply to the newsgroup


 
Reply With Quote
 
Bob I
Guest
Posts: n/a
 
      1st Dec 2006
..cmd files are batch files that are intended to run on NT based Windows
while .bat files will run in the "DOS based" Windows AND/OR "NT based"
Windows. So ".bat" files should not reference any NT only programs or
command.

John Goche wrote:

> Hello,
>
> Is there a difference between .cmd files and .bat files?
> More precisely, is there an established convention as
> to when to name a file containing a set of commands
> with the .cmd extension as opposed to with the .bat
> extension?
>
> Thanks,
>
> JG
>


 
Reply With Quote
 
Pop`
Guest
Posts: n/a
 
      1st Dec 2006
Bob I wrote:
> .cmd files are batch files that are intended to run on NT based
> Windows while .bat files will run in the "DOS based" Windows AND/OR
> "NT based" Windows. So ".bat" files should not reference any NT only
> programs or command.
>
> John Goche wrote:
>
>> Hello,
>>
>> Is there a difference between .cmd files and .bat files?
>> More precisely, is there an established convention as
>> to when to name a file containing a set of commands
>> with the .cmd extension as opposed to with the .bat
>> extension?
>>
>> Thanks,
>>
>> JG


That's incorrect; I just created a batch file that handles local gpo and and
another with some of the more mundane XP command prompt additions. It just
doesn't care. All they are is a script; what executes in one will execute
in the other.



 
Reply With Quote
 
Bob I
Guest
Posts: n/a
 
      4th Dec 2006
The operative words are INTENDED and SHOULD.
1. Go try running a .cmd file in Windows 95, 98, or ME
2. Try running a .bat file containing NT specific commands in Windows
95, 98, or ME.

Since you didn't try doing what the convention is intended to avoid, you
don't observe the problem of disregarding the convention. So, YOU would
be the one that is incorrect.

Pop` wrote:

> Bob I wrote:
>
>>.cmd files are batch files that are intended to run on NT based
>>Windows while .bat files will run in the "DOS based" Windows AND/OR
>>"NT based" Windows. So ".bat" files should not reference any NT only
>>programs or command.
>>
>>John Goche wrote:
>>
>>
>>>Hello,
>>>
>>>Is there a difference between .cmd files and .bat files?
>>>More precisely, is there an established convention as
>>>to when to name a file containing a set of commands
>>>with the .cmd extension as opposed to with the .bat
>>>extension?
>>>
>>>Thanks,
>>>
>>>JG

>
>
> That's incorrect; I just created a batch file that handles local gpo and and
> another with some of the more mundane XP command prompt additions. It just
> doesn't care. All they are is a script; what executes in one will execute
> in the other.
>
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:47 PM.