Escape Characters in Windows’ CMD.EXE

Software

I’m currently working with another developer on how to get random windows shell commands that are stored in a database to actually execute properly on a target system.  The idea is that we’ll Start() a new Process object, and execute the command as arguments.

Check out this screenshot:

Windows Command Shell

What we’re doing here is running the local ECHO command; which  will write out another ECHO command to a batch file which we can then execute.  A couple neat things which may help you:

The caret (^) character is an escape character for things like <, >, (, ), etc.    These are special shell characters.

You can quote the whole string.

I hope this helps the random Google searcher who arrives here.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Furl
  • Ma.gnolia
  • Reddit
  • TwitThis
7 Comments

7 Comments

  1. Jakub Lucký  •  Apr 27, 2008 @10:38 pm

    “I hope this helps the random Google searcher who arrives here.”

    Sure it does ;)

  2. Tabor  •  May 12, 2008 @4:26 pm

    It sure does help.

  3. Jon  •  Jul 19, 2008 @10:59 am

    Does indeed. I tried every combination of forward and backslashes imaginable. A caret? Heh.

  4. Random User  •  Jul 22, 2008 @11:53 pm

    Hi, thank you!

    I just want to confirm your wish… thank you again ^_^

  5. Inceva  •  Aug 20, 2008 @9:33 am

    I alot have tried every combination of forward and backslashes imaginable. Thank you so much for posting. If you ever need any help on a web project hit me up on ww.inceva.tk.

    Thanks!

  6. Wyrd  •  Sep 11, 2008 @9:36 am

    Yes, it does help. *Thank you*.

    The thing is, I think I knew this once, but then I forgot it.

    But what I was really trying to do still doesn’t seem to work.

    I was trying to take output like this:
    ping -n 1 | find “Reply” > 1pingout

    then I wanted to set the window title equal to the result of that ping.

    The way I tried doing it was:
    set /p MYTITLE= < 1pingout
    title %MYTITLE%

    This fails whenever MYTITLE contains a “<”, which it sometimes does if the ping return time was really small.

    Even with all the new options in set, I can’t see any way of escaping the “<” without using something Unixie.


    Furry cows moo and decompress.

  7. Burmese  •  Aug 30, 2009 @10:54 am

    in linux, you can escape with backslash \

Leave a Reply

Allowed tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">