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:
SET TEST1=THIS IS NICE
PS F:\> ./TEST.BAT
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 :-)
Hi! Did you find this useful or interesting? I have an email list coming soon, but in the meantime, if you ready anything you fancy chatting about, I would love to hear from you. You can contact me here or at stephen ‘at’ logicalmoon.com