Error: Command failed: wmic os get Caption 'wmic' is not recognized as an internal or external command, operable program or batch file.
Bug Report
What does actually happen?
Im getting this error after I updated to cordova 9.0.0
C:\Users\admin\AppData\Roaming\npm\node_modules\cordova\node_modules\execa\index
.js:347
throw err;
^
Error: Command failed: wmic os get Caption
'wmic' is not recognized as an internal or external command,
operable program or batch file.
at makeError (C:\Users\admin\AppData\Roaming\npm\node_modules\cordova\node_m
odules\execa\index.js:174:9)
at Function.module.exports.sync (C:\Users\admin\AppData\Roaming\npm\node_mod
ules\cordova\node_modules\execa\index.js:338:15)
at windowsRelease (C:\Users\admin\AppData\Roaming\npm\node_modules\cordova\n
ode_modules\windows-release\index.js:34:24)
at osName (C:\Users\admin\AppData\Roaming\npm\node_modules\cordova\node_modu
les\os-name\index.js:39:18)
at new Insight (C:\Users\admin\AppData\Roaming\npm\node_modules\cordova\node
_modules\insight\lib\index.js:37:13)
at Object.<anonymous> (C:\Users\admin\AppData\Roaming\npm\node_modules\cordo
va\src\telemetry.js:26:15)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
Information
Command or Code
cordova -v cordova help cordova build android
Version information
Cordova 9.0.0 Window 7 64x
Checklist
- [x ] I searched for existing GitHub issues
- [x ] I updated all Cordova tooling to most recent version
- [x ] I included all the necessary information above
Anything strange about your Windows installation?
Related: https://github.com/sindresorhus/windows-release/issues/10
Do you have c:\Windows\System32\wbem\WMIC.exe? Then this might help: https://superuser.com/a/1434268/25933
Anything strange about your Windows installation?
Uhmmm its not original copy
thanks @janpio, adding "c:\Windows\System32\wbem" to my path environnement variable solved this problem
thanks @janpio, adding "c:\Windows\System32\wbem" to my path environnement variable solved this problem
I have added this but still iam getting the same error! Even ionic info is not working. iam using windows-10 & ionic v-4.
my problem is the same, and solved with this cmd-->
alias ionic="cmd //C ionic $" alias cordova="cmd //C cordova $"
adding "c:\Windows\System32\wbem" to my path environnement variable solved this problem with Node v10 Also restart your cmd
Hello dear friends, I have such a problem too but it did not solve with this path now what should I do? I use ionic v5 and Cordova v9
I have the same problem. I tried commenting out the line (347) throwing the error and it worked
I have the same issue for days now
For me, this issue started occurring when I enabled Windows Credential Guard on my device. It should also be noted that the entire wmic utility is deprecated:

My opinion here is that Cordova is relying on a deprecated Windows component that may show undefined behaviour now and in the future since Microsoft will not keep testing whether new Windows versions and / or features might break it.
I found that this command can replace the call to wmic alltogether:
powershell (Get-CimInstance -Class Win32_OperatingSystem).Caption
I'll file an issue for this at the repository for the WindowsRelease module.
Filed this issue: https://github.com/sindresorhus/windows-release/issues/14.
I've made a pull request with a fix that uses powershell where wmic fails. Hoping it gets accepted. If not I cloned the repo and made a new version using the fix. Don't know if it's of any help to anyone, but here's the node package:
https://www.npmjs.com/package/windows-release-ps
sindresorhus have accepted my PR, so "windows-release" should be updated soon, and everything should be working again.
https://github.com/sindresorhus/windows-release/pull/15
I ALSO WORK WHEN ADD TO THE PATH " c:\Windows\System32\wbem" Thank's alot dude !!! win10 64bit
Finally after 2 days of trying everything imaginable i though that it was covid19. IT WORKS !!! ADD TO PATH " c:\Windows\System32\wbem" Thanks!! win10 64bit.
It worked for me. I fixed it by adding C:\Windows\System32\wbem to my environment path. Windows 8. Now cordova -v works well for me.
The underlying issue here is not whether or not wmic is on the path or not, the issue is that it is deprecated and may show undefined behaviour.
Just like @ArthurHNL says, adding wbem to the system path won’t work in future Windows releases since WMIC is deprecated. That’s why the windows-release package was updated to use Powershell I stead of WMIC as the first choice.
I am also getting this error and i was add path in system variables but it's not resolve Cordova -v getting this error