I want to be able to create an *.rdp file from a bat file, however I just noticed that rdp files are actually encoded as USC-2 LE BOM
, while my bat is producing a UTF-8
file, here's what I do:
@echo off
> file.rdp (
echo screen mode id:i:2
... bunch of echoes
echo lastparam:: )
This produces what I expected but is encoded in UTF-8
, is there a way to either:
- Create a file, set its encoding and then apend to it?
- Produce the output from
>
encoded inUSC-2 LE BOM
directly to a file? - Encode the
UTF-8
file intoUSC-2 LE BOM
within the same bat file?
I want to write this and other files using a bat so I can set Read-only permissions to the generated file and cannot think of any other alternative. This way, I'll be able to deploy a bunch of preconfigured read-only rdp files.
EDIT:
Thanks to LotPigs answer and this underrated answer I was able to use powershell to change the encoding, wanted to share how I was able to include the powershell encoding within the batch
@echo off
> utf8file ( ... )
ECHO Get-Content utf8file ^> utf16.rdp > powerShellScript.ps1
powershell.exe -ExecutionPolicy Bypass -File powerShellScript.ps1