检查WMIC是否安装,从批处理文件将数据写入文件
我使用 Windows Management Instrumentation 命令行 (WMIC) 从计算机读取数据,例如硬件组件和 IP 设置。
由于我使用批处理文件(Windows)用数据填充每台计算机/节点的文件,因此查询逻辑在那里实现。到目前为止,它在我的计算机和我尝试过的其他计算机上运行得很好。
问题出在以前未使用过 WMIC 的计算机上,有必要在第一次查询/执行时(自动)安装它。这就是为什么控制台程序打印出“Please wait while WMIC is being Installation”的原因。
当我写入我的文件时,这是一个问题:我不想在其中包含这个字符串。另一个问题是,如果输出该字符串,它会导致我的所有文件崩溃。 “正在安装 WMIC,请稍候”以 ASCII 表示,数据查询的结果以某种方式写入带有前导零的 ASCII 字符(多字节字符集?unicode?...)。
有人知道如何检查 WMIC 是否已安装? 或者:如何忽略该字符串? 或者:我真的必须在文件查看器中实现一个转换器来检查字符串/字符集吗?
I am using the Windows Management Instrumentation Command-line (WMIC) for reading data from a computer like it's Hardware components and IP settings.
As I am using a batch file (Windows) for filling files for each computer/node with data the query logic is implemented there. So far it has been working quite good on my computer and others I have tried on.
The problem is on computers where the WMIC has not been used before, it's neccessary to (automatically) be installed at the first query/execution. This is why the console program prints out "Please wait while WMIC is being installed".
As I am writing to my file this is a problem: I don't want to have this string in it. Another problem is, that if the string is output it crashes all my file. "Please wait while WMIC is being installed" is represented in ASCII, the results of the data queries are somehow written as ASCII characters with leading zeros (multi-byte character set? unicode? ...).
Does someone know how to check if WMIC is alread installed?
Or: how to ignore the string?
Or: do I really have to implement a converter in my file viewer which checks for the string/ character set?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于该信息仅在第一次运行 WMIC 时打印,因此您只需进行两次调用即可。一个虚拟的一个会吃掉字符串:
然后是你真正想要执行的。
Since that is only printed on the very first run of WMIC, you can just make two calls. One dummy one to eat away the string:
and after that what you actually wanted to execute.