How to write .CMD files from PowerShell?

后端 未结 1 2046
面向向阳花
面向向阳花 2021-02-19 21:09

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.

1条回答
  •  忘了有多久
    2021-02-19 21:36

    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
    

    0 讨论(0)
提交回复
热议问题