'wmic'不被识别为内部或外部命令,可操作程序或批处理文件


3

我需要运行我制作的这个脚本。该批次应该复制STM32 Nucleo上的编译程序。它用它wmic来查找Nucleo的虚拟驱动器的标签:

@echo off
for /f %%D in ('wmic volume get DriveLetter^, Label ^| find "NODE_F446RE"') do set nucleo_drive=%%D
IF EXIST %D%\DETAILS.TXT (
  IF EXIST main.bin (
    @echo on
    xcopy main.bin %D%
    @echo off
    echo Copied main.bin on nucleo
  ) ELSE (
    echo Binary not found. Run `mingw32-make` in this directory to compile the project.
  )
) ELSE (
  echo Nucleo drive not found. If needed, edit the `find "NODE_F446RE"` part of this script to refference your nucleo volume name.
)

但我得到这个错误:

'wmic' is not recognized as an internal or external command, operable program or batch file.

我确保Windows Management Instrumenation服务正在运行。还有什么可能是错的?


1
尝试绝对路径wmic,它应该居住C:\Windows\System32\wbem
亚历克斯

Answers:


12

这表示wmic在您的网站上找不到该实用程序的目录PATH。打开高级“系统属性”窗口(可以使用Windows+ 打开“系统”页面Pause/Break),然后在“高级”选项卡上单击“环境变量”。在系统变量部分中,查找PATH(或其任何大小写)。将此条目添加到其中:

%SystemRoot%\System32\Wbem

请注意,条目由分号分隔。


3
+ 1为我不知道的捷径:)
DavidPostill

在执行这些步骤之前,可能值得在升级(以管理员身份运行)命令行窗口中导航到此文件夹,以确保命令确实存在。
FreeText
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.