Quotes in MSDOS Batch Files

I recently needed to adapt an existing MSDOS batch file to use a cheeky PowerShell command to email a list of recipients. At the time, I though I needed to use quotes (I was wrong – you don’t) but nonetheless, I learnt a little about how MSDOS sets variables in batch files.

In short, it basically doesn’t do any interpretation at all and neither does it need to escape quote characters. Here are some test commands and below, you can see what happens when we run this as a batch file:


I won’t add any huge commentary because it is pretty easy to see exactly what you can expect, but I’d like to draw your attention to the fourth example. Can you see how I even put a quote around the SET command? That works too, but seems redundant.

Please file this information away in the “won’t be needing that, thank you” box 🙂


Written by Stephen Moon
email: stephen at logicalmoon.com
www: https://www.logicalmoon.com

Hey! Did you enjoy reading this? If you did and would like an email when I add new content, just subscribe to my list. You can unsubscribe at any time.

Leave a Reply

Your email address will not be published. Required fields are marked *