WMIC.bat文件将无法正确导出/输出 [英] WMIC.bat file will not export/output properly

查看:240
本文介绍了WMIC.bat文件将无法正确导出/输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在尝试在CMD中运行包含以下内容的批处理文件,

I am attempting to run a batch file in CMD that includes the following,

wmic csproduct
wmic cpu获得名称
wmic diskdrive获取型号,大小
ipconfig/全部

wmic csproduct
wmic cpu get name
wmic diskdrive get model,size
ipconfig /all

当我将其复制并粘贴到CMD中时,我可以看到命令的运行情况.我可以成功地将所有数据复制并粘贴到文本文档中,而不会出现问题.

问题:当我尝试将这个确切的文件导出/输出到.txt或.rtf时,

When I copy and paste this into CMD, I am able to watch the commands run. I am successfully able to copy and paste all of the data into a text document without issue.

The Issue: When I attempt to export/output this exact file into a .txt or .rtf,

C:> 1.bat> 1.txt

C:> 1.bat > 1.txt

"ipconfig"正确拉出,但是WMIC命令没有给我任何问题,并不能正确输出到该文件.但是,无论我以.txt还是.rtf格式导出/输出此批处理,

"ipconfig" pulls properly, yet the WMIC commands do not does not give me any issues and outputs to the file correctly. However, whether I export/output this batch as a .txt or .rtf,

WMIC命令在输出文件中的每个字符之间留有空格或NUL.

the WMIC commands are leaving spaces or NUL in between each character in the output file.

我将打开读取文件

C:\ Windows \ system32> wmic csproduct 卡普蒂恩·德塞斯·卡里普·诺伊·德纳西·科恩 科普特斯·普尔特·德·科特迪瓦·科普特·斯图尔特·普罗姆·德罗伊·科特迪瓦·科特迪瓦·科特迪瓦·科特迪瓦·科特迪瓦·科特迪瓦·科特迪瓦·科特迪瓦·科特迪瓦. E. M. T o b e f i l l e d b y O. E. M. C D 4 A E B A 0-B 7 4 F-1 2 D C-8 F B A-6 0 A 4 4 D 6 3 9 A B E E. M. T o b e f i l l e d b y O. E. M.
C:\ Windows \ system32> ipconfig/all

C:\Windows\system32>wmic csproduct C a p t i o n D e s c r i p t i o n I d e n t i f y i n g N u m b e r N a m e S K U N u m b e r U U I D V e n d o r V e r s i o n
C o m p u t e r S y s t e m P r o d u c t C o m p u t e r S y s t e m P r o d u c t T o b e f i l l e d b y O . E . M . T o b e f i l l e d b y O . E . M . C D 4 A E B A 0 - B 7 4 F - 1 2 D C - 8 F B A - 6 0 A 4 4 D 6 3 9 A B E T o b e f i l l e d b y O . E . M . T o b e f i l l e d b y O . E . M .
C:\Windows\system32>ipconfig /all

Windows IP配置

Windows IP Configuration

主机名. . . . . . . . . . . . :octocore
主Dns后缀. . . . . . . :
...等等...等

Host Name . . . . . . . . . . . . : octocore
Primary Dns Suffix . . . . . . . :
...etc...etc

是否有一种方法可以导出/输出此组合批处理",以便正确提取?

P.S.我试图阅读[ https://superuser.com/questions /812438/combine-batch-wmic-ansi-unicode-output-formatting] [1] ,但我的问题实际上包含一个批处理文件中的wmic和本机命令.

Is there a way to export/output this "combo batch" so that it pulls correctly?

P.S. I attempted to read [https://superuser.com/questions/812438/combine-batch-wmic-ansi-unicode-output-formatting][1] , but my question actually contains the wmic and native commands from one batch file.

[1]: https://superuser.com/questions/812438 /combine-batch-wmic-ansi-unicode-output-formatting

P.P.S.这是我在StackOverflow上的第一篇文章,所以在此先谢谢您! :)

[1]: https://superuser.com/questions/812438/combine-batch-wmic-ansi-unicode-output-formatting

P.P.S. This is my first post in StackOverflow, so thank you in advance! :)

推荐答案

WMIC输出为unicode.将每个wmic输出通过管道传输到more.

WMIC output is in unicode. Pipe each wmic output to more.

> 创建一个新文件.>> 创建一个新文件(如果尚不存在),并附加到该文件(如果存在)

> creates a new file.>> creates a new file if one does not already exist and appends to that file if it exists.

所以,治愈似乎是

wmic csproduct | more
wmic cpu get name | more
wmic diskdrive get model,size | more
ipconfig /all

这篇关于WMIC.bat文件将无法正确导出/输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆