since yesterday I try to create a batch file which writes several informations about the computer into a txt file which will later be used to keep a Database updates. The only problem is, that sometimes the output just ends up in random chinese symbols.
Here is an example of the current version of the batch files output.
SerialNumber
XXXXXX
Manufacturer
FUJITSU // American Megatrends Inc.
Name
Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz
Looks good so far but as soon as I want to add some text on my own or some bigger bits of information or normal text in between into the text file it writes it down in those damn symbols. Here is the output with "CPU" written between the Manufacturer and CPU information.
SerialNumber
XXXXXX
Manufacturer
FUJITSU // American Megatrends Inc.
偃⁕Name
Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz
The only problem is I have already tried to solve this problem with chcp 65001 and it still won't work properly. :/
Well here is the current code I'm using to write the informations into a txt file.
@SET PathSave=C:\Test.txt
@ECHO.
@ECHO Collecting Informations
@ECHO.
@ECHO Seriennummer
@wmic bios get serialnumber >> %PathSave%
@ECHO Marke
@wmic bios get manufacturer >> %PathSave%
@ECHO CPU
@wmic cpu get name >> %PathSave%
@ECHO Netzwerkadapter
@wmic nicconfig >> %PathSave%
@ECHO Press any key to complete!
@PAUSE > NUL
Maybe someone knows this cause already since I've seen some others trying to solve the problem, but everything I've tried so far didn't work.
There's a simple enough fix for times when you intend to read the UTF-16 LE (BOM) in a reader not compatible with that format.
Pipe the result through More
, e.g.
@WMIC CPU Get Name|MORE>>"%PathSave%"
…and:
@ECHO OFF
SET "PathSave=C:\Test.txt"
ECHO(
ECHO Collecting BIOS, CPU and Network Information
ECHO(
( WMIC BIOS Get Manufacturer,SerialNumber
WMIC CPU Get Name
WMIC NICConfig)|MORE>"%PathSave%"
ECHO Press any key to complete ...
PAUSE>NUL