BATCH 需要帮助来替换文本和特殊字符

BATCH need help to replace text and special characters

我有一个可以正常工作的批处理代码 returns:Belgi‰ 在某些时候。 所以我想在合并这些结果时将其更改为 België:

代码:

@echo off
systeminfo > Test2.txt

echo Please don't close the window, the program is still running...

findstr /C:"Host-naam:" /C:"Naam van besturingssysteem:" /C:"Geregistreerde     eigenaar:" /C:"Product-id:" /C:"Computermodel:" /C:"Computerfabrikant:" /C:"Type systeem:" /C:"Systeeminstellingen:" /C:"Landinstellingen voor invoer:" /C:"Totaal fysiek geheugen:" Test2.txt >> Test1.txt

echo This is the IPv4 adress: >> Test1.txt
ipconfig | findstr /R /C:"IPv4" >> Test1.txt
echo: >> Test1.txt

echo This is the IPv6 adress: >> Test1.txt
ipconfig | findstr /R /C:"IPv6" >> Test1.txt

DEL Test2.txt

EXIT

所以现在 returns 在某个时候:

Systeeminstellingen:                 nl-be;Nederlands (Belgi‰)
Landinstellingen voor invoer:        nl-be;Nederlands (Belgi‰)

我想要它回馈:

Systeeminstellingen:                 nl-be;Nederlands (België)
Landinstellingen voor invoer:        nl-be;Nederlands (België)

提前致谢

编辑1: 我尝试在系统信息上方添加 chcp 1252 > ... 它成功了,感谢您的帮助。

编辑2: 我刚刚看到我得到了他的 IPv6 地址输出,我想去掉 %14 和 %11 以及可能在它之后得到 %... 的所有其他地址。 我该怎么做?

Link-local IPv6-adres . . . . . . : fe80::1191:e4de:e3e9:277%14
Link-local IPv6-adres . . . . . . : fe80::e400:4433:12c3:2001%11

编辑3: 所以似乎有某种代码可以删除 IPv6 地址上的 % 符号。但是以下不起作用。

ipconfig | findstr /R /C:"IPv6" | findstr /v /r "%[0-9]" >> Test1.txt

如果您在文本编辑器中打开 Test1.txt 是否会显示错误的输出,或者仅当您通过命令行中的 "type Test1.txt" 或 "more Test1.txt" 查看时才会显示错误的输出?非 ASCII 字符通常在 cmd.exe 中显示不佳。您可以使用 "chcp" 命令将代码页更改为 65001 (chcp 65001) 以支持 unicode,但它会导致其他问题(例如 more 命令无法正常工作。

在批处理文件的开头添加 chcp 1252 更改代码页。
所以现在输出将采用正确的格式 (ANSI)。

第 2 部分:
%是地址范围
Why is there a percent sign '%' in the IPv6 address?

阅读