我有一个脚本,它从一个使用 C++ 构建的服务运行,而不是使用 unicode 构建的。 该程序运行下面的脚本,奇怪的是,运行 wmic qfe 列表行的脚本的输出似乎输出为 unicode。 示例输出如下。
这是脚本:
@echo off
echo This text is output as standard - no spacing between characters >>C:log.txt
REM this one is output with 1 space between characters
wmic qfe list >>C:log.txt
echo This text is also output as standard - no spacing >>C:log.txt
示例输出
This text is output as standard - no spacing between characters
C a p t i o n C S N a m e D e s c r i p t i o n F i x C o m m e n t s H o t F i x I D I n s t a l l D a t e I n s t a l l e d B y I n s t a l l e d O n N a m e S e r v i c e P a c k I n E f f e c t S t a t u s
h t t p : / / s u p p o r t . m i c r o s o f t . c o m / ? k b i d = 4 0 1 2 2 1 2 M F M - 7 4 2 - 0 - 7 1 S e c u r i t y U p d a t e K B 4 0 1 2 2 1 2 N T A U T H O R I T Y S Y S T E M 5 / 1 8 / 2 0 1 7
This text is also output as standard - no spacing
实际上,我只是使用十六进制编辑器查看了该文件,字母之间的字符是空字符。 所以大概WMIC QFE列表必须输出Unicode。
那么我如何将其全部输出为 ascii 或所有输出为 unicode。 所有输出为 ascii 将是首选。
wmic qfe list | find /v "" >> c:log.txt
wmic qfe list | findstr "^" >> c:log.txt
在将输出重定向到文件之前,将wmic
命令的输出通过管道传输到find
或findstr
命令(如果顺序没有问题,也可以使用sort
,如果输出少于 65535 行,也可以使用more
)。