I have a batch file with the following code to pull the current server CPU usage:
@echo off
for /f "tokens=2 delims==" %%i in ('wmic cpu get loadpercentage /value ^|find "="') do set /a cpu=%%i
echo %cpu%
Using ColdFusion's CFEXECUTE, I would like to run this batch file and return the echoed value:
<cfexecute name="#PathToBatchFile#" variable="Usage">
<cfdump var="#Usage#">
Running the above results in ColdFusion 2021 saying "Usage" is undefined.
The batch file can output the value to a file using the "outputfile" attribute --
<cfexecute name="#PathToBatchFile#" outputfile="#OutputFile#">
-- then I can use CFFILE to read it, but that seems rather roundabout. Anyone know what I could be doing wrong? Thanks!