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:

Output:

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 🙂

twittergoogle_plusredditpinteresttumblrmail

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


Leave a Reply

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