You are not logged in.

#1 22 May 2014 00:44

npocmaka
Member
From: Bulgaria
Registered: 03 Dec 2009
Posts: 446

Differences between batch-file and command prompt modes for CMD.EXE

Here's what pops-up in my mind at the moment:

1.These commands does not have effect in command prompt mode: SHIFT (also %1,%2 ... are inaccessible) ,SETLOCAL , ENDLOCAL , GOTO , CALL :LABEL

2.DOSKEY does not work in batch files

3.Double percentages when FOR is used in batch file , and single in command prompt and as whole in a lot of places % should be escaped with % in batch files.

4. CTL+leter produces extended ASCII chars in command prompt (in batch you are depending on the text editor)

5.TAB is auto completion in command prompt.

6.Arrows iterate through the previous commands in command prompt.

7.Enter executes a command in command prompt ...

Offline

#2 22 May 2014 03:18

Honguito98
Member
From: Mexico
Registered: 19 Sep 2013
Posts: 57

Re: Differences between batch-file and command prompt modes for CMD.EXE

Other stuff:
Some next stuff are executed in cmd.exe

1. Pressing 'Del' key when text cursor is at first of word, deletes any char from end to start.

2. Pressing 'Shift + Tab' does exactly the auto completion, but in inverse mode.

3. Pressing 'Insert' button enables insert mode and change the cursor size.

4. Using carets show the message 'More?', then here it's possible add another command line

5. Using parentheses is same function as above.

6. The command line '..\foldername' do change of dir. from current directory (only for file location) without change the current dir. (applies for batch files)

7. Using some chars like '@' ',' '=' ';' at first of some command line, it's ignored, if there is a valid command or program, it's executed. (applies for batch files)

8. Right Arrow performs a last command completion.

9. Pressing 'Ctrl + @' inserts a nul char (not tested by me).

10. PgUp (or RePág) uses the first command line used.

11. PgDn (or AvPág) uses the last command line used.

12. 'Set/a' command shows the result of any expression on screen.


.::{Honguito98}::.

Offline

#3 22 May 2014 06:46

Aacini
Member
Registered: 05 Dec 2012
Posts: 149

Re: Differences between batch-file and command prompt modes for CMD.EXE

@npocmaka:

Excuse me. I think you forgot that a Batch file is a (text) FILE! You may compare the different behaviour of cmd.exe program when it takes input in the command-prompt vs. when a Batch file is running, but certainly you can NOT compare cmd.exe vs. the behaviour of the text editor program used to create the Batch file! There are several programs you may use to create a Batch file (I use Turbo-Pascal in my old Windows XP computer, for example), so want you to compare cmd.exe vs. all of them? The points 2, 4, 5, 6 and 7 in your post (and most points in Honguito98's reply) are of this type. Just my opinion...

Antonio

Last edited by Aacini (22 May 2014 06:47)

Offline

#4 23 May 2014 20:01

npocmaka
Member
From: Bulgaria
Registered: 03 Dec 2009
Posts: 446

Re: Differences between batch-file and command prompt modes for CMD.EXE

I agree that the points listed by you are  an 'editor' specific.
Not entirely bad because I've never seen the all ctrl+.. symbols listed somewhere , and this thread is not a bad place for this smile

here it is:
 

>chcp
Active code page: 866 

>echo ^Q^W^E^R^T^Y^U^O^P^[^]^\
◄↨♣↕¶↓§☼►←↔∟

>echo ^^^_ (^@ is nul)
▲▼

>echo ^A^F^G^K^L  (^G is beep, ^H is backspace )
☺♠♂♀

>echo ^X^V^B^N (^Z is end of line , ^C is stop operation , ^M is enter)
↑▬☻♫

and these are all ctrl combinations that I've found

here are the printable ones with thei hex values:

echo ^^^_^Q^W^E^R^T^Y^U^O^P^[^]^\^A^F^G^K^L^X^V^B^N > test.file

000000	1E	1F	11	17	05	12	14	19	15	0F	10	1B	1D	1C	01	06	................
000010	07	0B	0C	18	16	02	0E	20	0D	0A	 	 	 	 	 	 	....... ..      

Does the code page has an effect over these?

Last edited by npocmaka (23 May 2014 20:07)

Offline

#5 23 May 2014 20:17

npocmaka
Member
From: Bulgaria
Registered: 03 Dec 2009
Posts: 446

Re: Differences between batch-file and command prompt modes for CMD.EXE

Honguito98 wrote:

Other stuff:
Some next stuff are executed in cmd.exe



7. Using some chars like '@' ',' '=' ';' at first of some command line, it's ignored, if there is a valid command or program, it's executed. (applies for batch files)


12. 'Set/a' command shows the result of any expression on screen.


Thanks for the reply :-) . In fact 7 is valid in command prompt too...

As for the 12 .Here is how you can display the result without variable :-D (but is rather not useful)

@echo off
goto :no_such_lablel >nul 2>&1|| set /a 2+2

In this case SET /A also prints the result without new line:

set /a 2+2 & set /a 2+2

Last edited by npocmaka (23 May 2014 20:19)

Offline

#6 24 May 2014 04:19

Liviu
Member
Registered: 02 May 2013
Posts: 8

Re: Differences between batch-file and command prompt modes for CMD.EXE

Editing aside, there are differences between batch mode vs. command line as far as undefined variables are handled (http://stackoverflow.com/questions/4094 … se-scripts), and how some internal commands reset the errorlevel (http://www.dostips.com/forum/viewtopic. … 619#p32619). Knowing cmd, I am pretty sure there must be other differences as well ;-)

npocmaka wrote:

Does the code page has an effect over these [control characters]?

All "native" codepages use the same encoding for control characters (http://msdn.microsoft.com/en-us/library … 52(v=vs.85).aspx - "for both Windows code pages and OEM code pages [...] code values 0x00 through 0x19 and 0x7F always represent standardized control characters"). Extended codepage 65001 (UTF-8) matches the same codes, as does UTF16 when cast down to a single byte. However, more esoteric extended/non-native codepages may encode the control characters differently, and some do - for example EBCDIC codepage IBM037 maps code 0x04 to U+9C (http://www.unicode.org/Public/MAPPINGS/ … /CP037.TXT).

Liviu

Offline

Board footer

Powered by