Cannot set a variable in a batch file -


i have following...

@echo off setlocal enabledelayedexpansion  /f "skip=1" %%p in ('wmic cpu loadpercentage') @echo %%p echo ...this worked echo.  pause  /f "skip=1" %%p in ('wmic cpu loadpercentage') set cpu=%%p echo cpu %cpu% echo ...this did not work echo.  pause 

how come can't set number in variable %cpu% it's blank!

for /f "skip=1" %%p in ('wmic cpu loadpercentage') set cpu=%%p & goto :end_for :end_for 

wmic produces empty line @ end.you can try /format:csv @ end of wmic call prevent that.

check this: http://www.dostips.com/forum/viewtopic.php?f=3&t=4266


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -