How does one write to a valid .CMD (or .BAT) file from PowerShell? I\'m using the > operator but cmd.exe can\'t execute the files I create.
>
cmd.exe
Set-Content bar.cmd '@set BAR=1' -Encoding ASCII
PowerShell will default to UTF-16 LE.
Short version.
sc bar.cmd '@set BAR=1' -en ASCII