User Tools

Site Tools


computing:environments:ms-dos

'MS-DOS'

'echo' without trailing newline

To echo a text without the writing of the ending newline (like echo -n under POSIX), type :

echo | set /p="<text>"

where <text> is the text to display.

This commands returns an errorlevel of 1, so you have to add || true to reset the errorlevel.

Setting a variable with the result of a command

To put the result of a command in an environment variable, type :

<command> > <file>
- set /p <variable>= < <file>

where :

  • <command> is the command from which you want to retrieve the result,
  • <variable> the name of the environment variable in which you want to store the result of the above command,
  • <file> : the name of a temporary file which can be deleted afterwards.

DOS command return value

The return value of a DOS command can be retrieved through %ERRORLEVEL%. A value other then 0 usually indicates an error.

computing/environments/ms-dos.txt · Last modified: Fri Jun 16 10:39:20 2017 (16/06/17) by Claude SIMON