PC Review Forums Newsgroups Windows 2000 Microsoft Windows 2000 CMD Promt Difference between .cmd & .bat files?



Reply

Difference between .cmd & .bat files?

 
Thread Tools Rate Thread
Old 18-07-2003, 06:40 PM   #1
Gregory Mamayek
Guest
 
Posts: n/a
Default Difference between .cmd & .bat files?

Gang:\>

How come some files fire using .cmd, while others use .bat?
When would you use either one?

Is it because .cmd is for execution, while .bat is used to provide a
data source (ie. like web page .htm using SQL to call data source .bat)?

--
Cordially,
Greg
A+ BS MCSE Web Developer


  Reply With Quote
Old 18-07-2003, 06:46 PM   #2
Gregory Mamayek
Guest
 
Posts: n/a
Default Re: Difference between .cmd & .bat files?

Gang:\>

I looked at the extensions, so I see the different properties.

Also, is debug a good way to get more information about what's going on
compared to the last result: 0x0 field in scheduled tasks?

Gregory Mamayek wrote:

> Gang:\>
>
> How come some files fire using .cmd, while others use .bat?
> When would you use either one?
>
> Is it because .cmd is for execution, while .bat is used to provide a
> data source (ie. like web page .htm using SQL to call data source .bat)?
>
> --
> Cordially,
> Greg
> A+ BS MCSE Web Developer


--
Cordially,
Greg
A+ BS MCSE Web Developer


  Reply With Quote
Old 18-07-2003, 06:50 PM   #3
Dean Wells [MVP]
Guest
 
Posts: n/a
Default Re: Difference between .cmd & .bat files?

No difference in behavior ... whatsoever ... in the context of this
newsgroup at least.

Legacy extension implying batch of commands = .BAT
Uplevel extension implying shell script = .CMD

..BAT = common to x-DOS operating systems
..CMD = used by OS/2 and introduced in Windows NT4

Dean

--
Dean Wells [MVP / Windows platform]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l


"Gregory Mamayek" <gmamayek@dllr.state.md.us> wrote in message
news:3F183117.8F694280@dllr.state.md.us...
> Gang:\>
>
> How come some files fire using .cmd, while others use .bat?
> When would you use either one?
>
> Is it because .cmd is for execution, while .bat is used to provide a
> data source (ie. like web page .htm using SQL to call data source

..bat)?
>
> --
> Cordially,
> Greg
> A+ BS MCSE Web Developer
>
>



  Reply With Quote
Old 18-07-2003, 07:15 PM   #4
Gregory Mamayek
Guest
 
Posts: n/a
Default Re: Difference between .cmd & .bat files?

Dean:

Thanx for reply.

I am running WIN2K, but I do see a difference in that the .cmd's work,
while the .bat's don't. If I understand you correctly, this may be due to
the OS, or maybe it's the commands I'm using within the batch files.

I will have to play with some more examples to examine their behavior.

The best example is Ritchie's HTML CMD tool. It didn't work when I named
the batch file with .bat, but worked when I used .cmd.

Just a newbie...LOL


"Dean Wells [MVP]" wrote:

> No difference in behavior ... whatsoever ... in the context of this
> newsgroup at least.
>
> Legacy extension implying batch of commands = .BAT
> Uplevel extension implying shell script = .CMD
>
> .BAT = common to x-DOS operating systems
> .CMD = used by OS/2 and introduced in Windows NT4
>
> Dean
>
> --
> Dean Wells [MVP / Windows platform]
> MSEtechnology
> [[ Please respond to the Newsgroup only regarding posts ]]
> R e m o v e t h e m a s k t o s e n d e m a i l
>
> "Gregory Mamayek" <gmamayek@dllr.state.md.us> wrote in message
> news:3F183117.8F694280@dllr.state.md.us...
> > Gang:\>
> >
> > How come some files fire using .cmd, while others use .bat?
> > When would you use either one?
> >
> > Is it because .cmd is for execution, while .bat is used to provide a
> > data source (ie. like web page .htm using SQL to call data source

> .bat)?
> >
> > --
> > Cordially,
> > Greg
> > A+ BS MCSE Web Developer
> >
> >


--
Cordially,
Greg
A+ BS MCSE Web Developer


  Reply With Quote
Old 18-07-2003, 08:16 PM   #5
Dean Wells [MVP]
Guest
 
Posts: n/a
Default Re: Difference between .cmd & .bat files?

I've not seen Richie's script, can you post it?

I've discovered no differences in the behavior between .BAT and .CMD
from Windows 2000 onwards.

Dean

--
Dean Wells [MVP / Windows platform]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l


"Gregory Mamayek" <gmamayek@dllr.state.md.us> wrote in message
news:3F183930.6056EC31@dllr.state.md.us...
> Dean:
>
> Thanx for reply.
>
> I am running WIN2K, but I do see a difference in that the .cmd's work,
> while the .bat's don't. If I understand you correctly, this may be due

to
> the OS, or maybe it's the commands I'm using within the batch files.
>
> I will have to play with some more examples to examine their behavior.
>
> The best example is Ritchie's HTML CMD tool. It didn't work when I

named
> the batch file with .bat, but worked when I used .cmd.
>
> Just a newbie...LOL
>
>
> "Dean Wells [MVP]" wrote:
>
> > No difference in behavior ... whatsoever ... in the context of this
> > newsgroup at least.
> >
> > Legacy extension implying batch of commands = .BAT
> > Uplevel extension implying shell script = .CMD
> >
> > .BAT = common to x-DOS operating systems
> > .CMD = used by OS/2 and introduced in Windows NT4
> >
> > Dean
> >
> > --
> > Dean Wells [MVP / Windows platform]
> > MSEtechnology
> > [[ Please respond to the Newsgroup only regarding posts ]]
> > R e m o v e t h e m a s k t o s e n d e m a i l
> >
> > "Gregory Mamayek" <gmamayek@dllr.state.md.us> wrote in message
> > news:3F183117.8F694280@dllr.state.md.us...
> > > Gang:\>
> > >
> > > How come some files fire using .cmd, while others use .bat?
> > > When would you use either one?
> > >
> > > Is it because .cmd is for execution, while .bat is used to provide

a
> > > data source (ie. like web page .htm using SQL to call data source

> > .bat)?
> > >
> > > --
> > > Cordially,
> > > Greg
> > > A+ BS MCSE Web Developer
> > >
> > >

>
> --
> Cordially,
> Greg
> A+ BS MCSE Web Developer
>
>



  Reply With Quote
Old 18-07-2003, 08:37 PM   #6
Ritchie
Guest
 
Posts: n/a
Default Re: Difference between .cmd & .bat files?

"Dean Wells [MVP]" <dwells@mask.msetechnology.com> wrote in message news:#v1wLUVTDHA.2768@tk2msftngp13.phx.gbl...
> No difference in behavior ... whatsoever ... in the context of this
> newsgroup at least.


I don't mean to be picky, but that's not strictly true. Create two copies
of the script below, save one as a .bat, the other as a .cmd:-

@echo off&setlocal ENABLEEXTENSIONS
call :func&&echo/I'm a cmd||echo/I'm a bat
goto :EOF

:func
md;2>nul
set var=1

I think .cmd is the preferred extension for NT/2000/XP/2003 scripts.

--
Ritchie



  Reply With Quote
Old 18-07-2003, 09:07 PM   #7
NuT CrAcKeR
Guest
 
Posts: n/a
Default Re: Difference between .cmd & .bat files?

Since no one else has added this to the mix... here it goes.

..bat extetions are executed in a 16bit VDM while .cmd extentions are
executed in a 32bit VDM. This has implications for scripts that may need to
access shared memory from other processes or applications.

..... this is an addendum to what the others in the group have already said.

NuTs

"Gregory Mamayek" <gmamayek@dllr.state.md.us> wrote in message
news:3F183117.8F694280@dllr.state.md.us...
> Gang:\>
>
> How come some files fire using .cmd, while others use .bat?
> When would you use either one?
>
> Is it because .cmd is for execution, while .bat is used to provide a
> data source (ie. like web page .htm using SQL to call data source .bat)?
>
> --
> Cordially,
> Greg
> A+ BS MCSE Web Developer
>
>



  Reply With Quote
Old 18-07-2003, 09:43 PM   #8
Dean Wells [MVP]
Guest
 
Posts: n/a
Default Re: Difference between .cmd & .bat files?

Hi Richie,

I've tested your enclosed syntax on 2000, XP and 2003. The bahavior of
the .BAT script is is identical to that of the .CMD script on all 3
platforms ... unless I'm missing the difference you're attempting to
exhibit.

Dean

--
Dean Wells [MVP / Windows platform]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l


"Ritchie" <qiournvdlirhjgiuhdiuh345@hotmail.com> wrote in message
news:bf9iad$cgcjq$1@ID-156657.news.uni-berlin.de...
> "Dean Wells [MVP]" <dwells@mask.msetechnology.com> wrote in message

news:#v1wLUVTDHA.2768@tk2msftngp13.phx.gbl...
> > No difference in behavior ... whatsoever ... in the context of this
> > newsgroup at least.

>
> I don't mean to be picky, but that's not strictly true. Create two

copies
> of the script below, save one as a .bat, the other as a .cmd:-
>
> @echo off&setlocal ENABLEEXTENSIONS
> call :func&&echo/I'm a cmd||echo/I'm a bat
> goto :EOF
>
> :func
> md;2>nul
> set var=1
>
> I think .cmd is the preferred extension for NT/2000/XP/2003 scripts.
>
> --
> Ritchie
>
>
>



  Reply With Quote
Old 18-07-2003, 09:56 PM   #9
Dean Wells [MVP]
Guest
 
Posts: n/a
Default Re: Difference between .cmd & .bat files?

I stand corrected ... I've just this seond noticed the difference
(opening my eyes must have helped

That's an interesting behavioral difference ... I'll do some digging and
see what else turns up.

Dean

--
Dean Wells [MVP / Windows platform]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l


"Dean Wells [MVP]" <dwells@mask.msetechnology.com> wrote in message
news:eELLM1WTDHA.2768@tk2msftngp13.phx.gbl...
> Hi Richie,
>
> I've tested your enclosed syntax on 2000, XP and 2003. The bahavior of
> the .BAT script is is identical to that of the .CMD script on all 3
> platforms ... unless I'm missing the difference you're attempting to
> exhibit.
>
> Dean
>
> --
> Dean Wells [MVP / Windows platform]
> MSEtechnology
> [[ Please respond to the Newsgroup only regarding posts ]]
> R e m o v e t h e m a s k t o s e n d e m a i l
>
>
> "Ritchie" <qiournvdlirhjgiuhdiuh345@hotmail.com> wrote in message
> news:bf9iad$cgcjq$1@ID-156657.news.uni-berlin.de...
> > "Dean Wells [MVP]" <dwells@mask.msetechnology.com> wrote in message

> news:#v1wLUVTDHA.2768@tk2msftngp13.phx.gbl...
> > > No difference in behavior ... whatsoever ... in the context of

this
> > > newsgroup at least.

> >
> > I don't mean to be picky, but that's not strictly true. Create two

> copies
> > of the script below, save one as a .bat, the other as a .cmd:-
> >
> > @echo off&setlocal ENABLEEXTENSIONS
> > call :func&&echo/I'm a cmd||echo/I'm a bat
> > goto :EOF
> >
> > :func
> > md;2>nul
> > set var=1
> >
> > I think .cmd is the preferred extension for NT/2000/XP/2003 scripts.
> >
> > --
> > Ritchie
> >
> >
> >

>
>



  Reply With Quote
Old 18-07-2003, 10:35 PM   #10
Dean Wells [MVP]
Guest
 
Posts: n/a
Default Re: Difference between .cmd & .bat files?

It appears to require 3 components (at least that I've found so far) in
order to trigger the behavioral difference -

1. Use of a call statement
2. An error of some kind
3. an environment modification

Does this concur with your own findings?

Dean

--
Dean Wells [MVP / Windows platform]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l


"Ritchie" <qiournvdlirhjgiuhdiuh345@hotmail.com> wrote in message
news:bf9iad$cgcjq$1@ID-156657.news.uni-berlin.de...
> "Dean Wells [MVP]" <dwells@mask.msetechnology.com> wrote in message

news:#v1wLUVTDHA.2768@tk2msftngp13.phx.gbl...
> > No difference in behavior ... whatsoever ... in the context of this
> > newsgroup at least.

>
> I don't mean to be picky, but that's not strictly true. Create two

copies
> of the script below, save one as a .bat, the other as a .cmd:-
>
> @echo off&setlocal ENABLEEXTENSIONS
> call :func&&echo/I'm a cmd||echo/I'm a bat
> goto :EOF
>
> :func
> md;2>nul
> set var=1
>
> I think .cmd is the preferred extension for NT/2000/XP/2003 scripts.
>
> --
> Ritchie
>
>
>



  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off