Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 为什么此wmic命令在批处理文件中不起作用_Windows_Batch File_Wmic - Fatal编程技术网

Windows 为什么此wmic命令在批处理文件中不起作用

Windows 为什么此wmic命令在批处理文件中不起作用,windows,batch-file,wmic,Windows,Batch File,Wmic,我有一套程序,我需要安装,卸载等通过批处理文件。 所以我的批处理文件包含这一行 wmic product where name="ABCcorp Tool" get version 除了这个工具外,它工作正常 wmic product where name="XYZ® Tool" get version 它只是打印 No Instance(s) Available. 如果我直接通过命令行(管理员运行)运行相同的命令,效果会非常好 我怀疑那个注册标志是罪魁祸首,就把它改成了 wmic pro

我有一套程序,我需要安装,卸载等通过批处理文件。 所以我的批处理文件包含这一行

wmic product where name="ABCcorp Tool" get version
除了这个工具外,它工作正常

wmic product where name="XYZ® Tool" get version
它只是打印

No Instance(s) Available.
如果我直接通过命令行(管理员运行)运行相同的命令,效果会非常好

我怀疑那个注册标志是罪魁祸首,就把它改成了

wmic product where "Name like 'XYZ%'" get version
同样的问题:直接在命令行上运行,但不通过批处理文件运行。
我应该在这里做什么?

这与其说是解决方案,不如说是一种变通方法。 我想出了如何正确地得到“像这样的名字”。基本上应该是这样

wmic product where "Name like 'XYZ%%'" get version
在批处理文件中,因为%是需要转义的特殊字符


因此,我的问题解决了,但如果有人知道如何使用“®”符号,它可能对其他人有用。

打开命令提示窗口,运行
chcp
,根据您的Windows区域和语言设置显示您的计算机上为您的帐户使用的代码页。您可以在Wikipedia上找到各种代码页,例如(美国、加拿大),(西欧国家),(在北美、西欧的GUI应用程序中)。您的问题是由于在编写批处理代码时没有使用正确的代码页造成的。