Can't run bat files when using anything other than 'ta' with 'writefile'

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
1024mb
Posts: 230
Joined: 14 Dec 2018 23:26
Location: Windows 10 @ 100%

Can't run bat files when using anything other than 'ta' with 'writefile'

Post by 1024mb »

I'm creating a bat file using 'writefile' with success, the problem comes when I need to write the file as UNICODE, if I use tu or r, the file is created but I can't execute it. My system is 1252. I have to use UNICODE because some of the text in the batch file is Russian and using ANSI outputs ??????? instead of the real text, this is a sample of what XYplorer should write:

Code: Select all

cd /D "O:\Gunther & The Sunshine Girls СинглоГрафия"
Using 'ta' results in ????? instead of the Russian text, using tu results in a correct file (at least apparently) but can't run it, same if I use 'r'. What I'm I missing here? Can someone test this? Maybe my machine is the problem.

I have tried running the file by double clicking it and also by opening a cmd window and executing the bat from there (so I can see the output but it shows nothing at all, like I did nothing).

PS: Also, why using utf8 or even utf8bom gives the same results as using ta? UTF-8 should be OK and the Russian text be written correctly, isn't it?

EDIT: Ok, with the sample that I shared above my cmd window now says:
"■c" not recognized as an internal or external command, program, or executable batch file.
Whereas before, minutes ago, it didn't output anything.
Last edited by 1024mb on 15 Aug 2021 08:36, edited 1 time in total.

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Can't run bat files when using anything other than 'ta' with 'writefile'

Post by highend »

use a chcp 65001
at the beginning of the bat content
and write it as utf8
One of my scripts helped you out? Please donate via Paypal

1024mb
Posts: 230
Joined: 14 Dec 2018 23:26
Location: Windows 10 @ 100%

Re: Can't run bat files when using anything other than 'ta' with 'writefile'

Post by 1024mb »

highend wrote: ↑15 Aug 2021 08:35 use a chchp 65001
at the beginning of the bat content
and write it as utf8
Thank you, that worked.
I didn't know how I managed to fix it before (at least it worked once) but then it stopped working with accented characters (and the 'ñ') so I had to put it like it was before but with your solution it works with both. :appl:

Post Reply