% ~ in REM expression

I noticed in the Windows batch file, even if you selected % ~ , you will get an error

For valid formats type CALL /? or FOR /?
The syntax of the command is incorrect.

Why is the comment line not ignored?

@ ECHO OFF
REM Blah blah blah
REM %~ this will cause an error
REM %%~ Double the fun, no error
+4
source share
2 answers

REM is an ECHO command . Run in a command prompt window rem /?to get help on this command.

First, the Windows command interpreter parses this command line, like all other lines in a batch file, except for those lines that begin with a colon, which are interpreted as a label line, and not as a command line.

, % , REM . , .

%~ . , REM , Windows. , cmd.exe .

@ ECHO OFF, , Windows. , , .

script . Windows Command Interpreter (CMD.EXE)?

:

REM User name: %USERNAME%
REM User profile directory: %USERPROFILE%
REM Application data directory: %APPDATA%
REM Batch arguments: %0 %*
PAUSE

REM @ECHO OFF .

+5

() . :

REM %~ this will cause an error

, , , cmd.exe %~

+4

Source: https://habr.com/ru/post/1679227/


All Articles