Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

10
  • 1
    In case you had DelayedExpansion enabled and would like to save !errorlevel! it would be something like echo ^^!errorlevel^^!>error.txt Commented Mar 2, 2022 at 16:34
  • 1
    @iTwasnTme >error.txt echo ^!!errorlevel^!! saves the error number but I think we are talking about saving the word errorlevel with percentage or exclamation marks here.... Commented Mar 2, 2022 at 21:30
  • 1
    @Ghost_Dz: (1) It appears from the question that the OP wants to write the twelve graphical characters %errorlevel% to the file.  Your suggestion writes only the ten graphical characters errorlevel.  The question also shows that the OP knows that echo something > filename will write something to the file, so if they had wanted to write the ten graphical characters errorlevel, they would have known enough to do echo errorlevel > error.txt. … (Cont’d) Commented Mar 5, 2022 at 22:09
  • 1
    (Cont’d) …  So why do you believe that your suggestion is relevant or useful?  (2) The whole point of my suggestion with the parentheses is to allow a somewhat-aesthetic (i.e., “pretty”-looking) command — with spaces before and after the > — that doesn’t silently write a space to the file.  (Users of English — and remember that English is the official language of Stack Exchange — are accustomed to seeing graphical characters immediately after ( and before ), with no intervening space. … (Cont’d) Commented Mar 5, 2022 at 22:09
  • 1
    (Cont’d) …  But when you see %>, with no intervening space, it’s less obvious that they are parts of two separate tokens.)  But, since you included a space before the ) in your command, it writes the eleven printable characters errorlevel⁠ ⁠, including the space (and also CR and LF).  So what’s the point? Commented Mar 5, 2022 at 22:09