简体   繁体   中英

Batch file doesn't read flags correctly

I've got a little batch file and it looks like this:

.\batchisp.exe –device at32uc3b1512 –hardware usb –operation erase f memory flash blankcheck loadbuffer G3Pro_USB.hex program verify start reset 0

The whole line is fine and works correctly if I run it straight in PowerShell. However, if I run the batch file, it runs this:

.\batchisp.exe ΓÇôdevice at32uc3b1512 ΓÇôhardware usb ΓÇôoperation erase f memory flash blankcheck loadbuffer G3Pro_USB.hex program verify start reset 0

Which does not work, because as you can see, the - 's have changed into ΓÇô 's... Can anybody tell me why this is and how to fix it?

This is because the marks are not - characters. They are actually endashes . These usually are caused by Word's automatic en/emdashing .

Powershell is smart enough to convert the endashes to dashes as "arguments", but cmd is not.

To fix this issue, replace with - . A regex search/replace that catches all the alternative dash types that works in notepad++ is: [–—‒] to - .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM