cordova-cli icon indicating copy to clipboard operation
cordova-cli copied to clipboard

Error: Command failed: wmic os get Caption 'wmic' is not recognized as an internal or external command, operable program or batch file.

Open originalnoob opened this issue 7 years ago • 31 comments

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

originalnoob avatar May 09 '19 20:05 originalnoob

Anything strange about your Windows installation?

janpio avatar May 09 '19 20:05 janpio

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

janpio avatar May 09 '19 20:05 janpio

Anything strange about your Windows installation?

Uhmmm its not original copy

originalnoob avatar May 09 '19 21:05 originalnoob

thanks @janpio, adding "c:\Windows\System32\wbem" to my path environnement variable solved this problem

MaryemZOBI avatar May 10 '19 13:05 MaryemZOBI

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.

prashanthrpr avatar Jun 20 '19 06:06 prashanthrpr

my problem is the same, and solved with this cmd-->

alias ionic="cmd //C ionic $" alias cordova="cmd //C cordova $"

fikalefaza avatar Jul 23 '19 08:07 fikalefaza

adding "c:\Windows\System32\wbem" to my path environnement variable solved this problem with Node v10 Also restart your cmd

lokibhardwaj avatar Aug 30 '19 09:08 lokibhardwaj

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

MohammadAsef2019 avatar Oct 10 '19 23:10 MohammadAsef2019

I have the same problem. I tried commenting out the line (347) throwing the error and it worked

IsaiahTek avatar Nov 07 '19 10:11 IsaiahTek

I have the same issue for days now

Nazehs avatar Nov 12 '19 20:11 Nazehs

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:

image

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.

ArthurHNL avatar Feb 09 '20 16:02 ArthurHNL

Filed this issue: https://github.com/sindresorhus/windows-release/issues/14.

ArthurHNL avatar Feb 09 '20 16:02 ArthurHNL

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

landsfiskalen avatar Mar 27 '20 00:03 landsfiskalen

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

landsfiskalen avatar Apr 06 '20 10:04 landsfiskalen

I ALSO WORK WHEN ADD TO THE PATH " c:\Windows\System32\wbem" Thank's alot dude !!! win10 64bit

rars15 avatar Apr 21 '20 03:04 rars15

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.

Abxabx avatar Apr 22 '20 03:04 Abxabx

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.

devsalimsulaiman avatar May 11 '20 23:05 devsalimsulaiman

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.

ArthurHNL avatar May 12 '20 05:05 ArthurHNL

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.

landsfiskalen avatar May 12 '20 14:05 landsfiskalen

I am also getting this error and i was add path in system variables but it's not resolve Cordova -v getting this error

sbairagi avatar Jun 17 '20 18:06 sbairagi