问题描述
我正在尝试在CMD中运行包含以下内容的批处理文件,
I am attempting to run a batch file in CMD that includes the following,
当我将其复制并粘贴到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,
"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.
我将打开读取文件
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文件将无法正确导出/输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!