1.

Solve : Difference between .cmd and .bat?

Answer»

Hi everyone,

Can someone TELL me the difference between .cmd and .bat

I'm asking as I have both on my computer...

I'm creating a master .bat (Mon.bat) that will :-
1. Call the .cmd file (which paths system drives)
2. Copies some files
3. Calls another .bat that STARTS a program

-- --------------------------------------------------------
Mong.bat

J:\cae_prog\pdms\v11.6\ECSArea\PDMS\pathing\Mon_Network.cmd
ping localhost -n 10 >nul
ECHO OFF
COPY J:\cae_prog\pdms\v11.6\Area\PDMS\bat\Copy_bats\mon_evars.bat C:\cae_prog\pdms\v11.6\CadCentre
ECHO mong_evars copied
COPY J:\cae_prog\pdms\v11.6\Area\PDMS\bat\Copy_bats\mon_pdms.bat C:\cae_prog\pdms\v11.6\CadCentre
ECHO mong_pdms copied

CALL C:\cae_prog\pdms\v11.6\CadCentre\mon_pdms.bat

-- --------------------------------------------------------
Mon_Network.cmd

echo off
color 1f

echo.
echo ---------------------------------------------
echo Connecting to Mon PDMS Server ... Please wait ...
echo ---------------------------------------------
echo.

echo Map Network Drive Z:

echo on

-- --------------------------------------------------------

My problem is...the .cmd executes okay...
but it stops there...the files aren't copied and the bat isn't executed either...

So can anyone tell me why my .bat isn't executing ?

Cheers
Neil Quote

-- --------------------------------------------------------
Mong.bat

J:\cae_prog\pdms\v11.6\ECSArea\PDMS\pathing\Mon_Network.cmd
ping localhost -n 10 >nul
ECHO OFF
COPY J:\cae_prog\pdms\v11.6\Area\PDMS\bat\Copy_bats\mon_evars.bat C:\cae_prog\pdms\v11.6\CadCentre
ECHO mong_evars copied
COPY J:\cae_prog\pdms\v11.6\Area\PDMS\bat\Copy_bats\mon_pdms.bat C:\cae_prog\pdms\v11.6\CadCentre
ECHO mong_pdms copied

CALL C:\cae_prog\pdms\v11.6\CadCentre\mon_pdms.bat

Batch/Command files need to be called to have control passed back to the caller. You have it right in the last line of your file.

Quote
-- --------------------------------------------------------
Mong.bat

CALL J:\cae_prog\pdms\v11.6\ECSArea\PDMS\pathing\Mon_Network.cmd
ping localhost -n 10 >nul
ECHO OFF
COPY J:\cae_prog\pdms\v11.6\Area\PDMS\bat\Copy_bats\mon_evars.bat C:\cae_prog\pdms\v11.6\CadCentre
ECHO mong_evars copied
COPY J:\cae_prog\pdms\v11.6\Area\PDMS\bat\Copy_bats\mon_pdms.bat C:\cae_prog\pdms\v11.6\CadCentre
ECHO mong_pdms copied

CALL C:\cae_prog\pdms\v11.6\CadCentre\mon_pdms.bat

Quote
Can someone tell me the difference between .cmd and .bat

As far as I know there are none. CMD files came along with WinNT. Both are text files which are executed within an interpreter.

 Thanks Sidewinder...you've saved me again...

Cheers
Neil Quote from: Sidewinder on APRIL 20, 2010, 08:09:03 AM

As far as I know there are none. CMD files came along with WinNT. Both are text files which are executed within an interpreter.


Scripts to be interpreted by command.com (the old MS-DOS command interpreter) need to have the .bat extension. Scripts to be interpreted by cmd.exe can have either the .bat or the .cmd extension. Put another way, a .bat script can be interpreted by either command.com or cmd.exe, whereas a .cmd file can only be RUN with cmd.exe. If both .bat and .cmd versions of a script (test.bat, test.cmd) are in the same folder and you run the script without the extension (test), by default the .bat version of the script will run, even on 64-bit Windows 7. The order of execution is controlled by the PATHEXT environment variable.

Didn't the REXX interpreter included with PC-DOS USE the cmd extension? Quote from: BC_Programmer on April 20, 2010, 02:24:28 PM
Didn't the REXX interpreter included with PC-DOS use the cmd extension?

Yes, indeed.


Discussion

No Comment Found