'C:\wmic' is not recognized as an internal or external command, operable program or batch file
You have two problems, both of which we explored in the comments above:
The actual WMIC binary is located at
C:\Windows\System32\wbem\WMIC.exe
, notC:\wmic
. That path needs to be used in your PHP command.You are trying to use Unix-style shell concepts (redirecting
STDERR
toSTDOUT
, chaining commands with;
, and usingecho
and$?
) on a Windows system.Simply running the command without all that stuff should work:
echo shell_exec("C:\\Windows\\System32\\wbem\\WMIC.exe cpu get loadpercentage");
set path Windows+Pausebreak
> Advanced System Settings
> Environment Variable
> systme varible
> path
> Edit
: C:\Windows\System32\wbem
or
Go C:\Windows\System32\wbem
> wbemtest
and connect then exit.