Want to use 'Battstat.cmd' on win 7.
I have successfully used 'Battstat.cmd' on Win XP for some time now. As to the code what has changed from XP to 7 in the 'WMIC.exe' file to make the 'Battstat.cmd' (see code below) batch file unresponsive? It seems the variables in the batch file do not correspond to the new 'WMIC.exe' file in Win 7. I can not find any information on what variables have changed in the new 'WMIC.exe.' If someone could point me in the right direction I would very much appreciate that. @echo off :: BattStat.cmd :: Test if command line extensions are enabled. if "%~1"=="~1" goto:ExtensionsAreNotEnabled :: Display help when the /? parameter is passed. if NOT "%~1"=="/?" goto:SkipHelp: :Help echo. echo Display current battery status for the local computer. echo. echo Usage: %~n0 echo. goto:EOF :ExtensionsAreNotEnabled echo Command line extensions are not enabled. They must be enabled for %~n0 to work properly. echo %~n0 aborted. echo. goto:Help :SkipHelp :: Check for Windows NT 4 or later (though XP or later is required) IF NOT "%OS%"=="Windows_NT" GOTO:Syntax :: Localize variables setlocal :: No command line arguments required IF NOT "%~1"=="" GOTO:Syntax :: Check if WMIC.EXE is available WMIC.EXE Alias /?:Brief >NUL 2>&1 || GOTO:Syntax :: Use WMI to retrieve battery status information FOR /F "tokens=1* delims==" %%A IN ('WMIC/NameSpace:"\\root\WMI" Path Battery_Status Get Charging^,Critical^,Discharging/Format:list ^| FIND "=TRUE"') DO ECHO Battery is %%A FOR /F "tokens=* delims= " %%A IN ('WMIC/NameSpace:"\\root\WMI" Path Battery_Status Get PowerOnline^,RemainingCapacity/Format:list ^| FIND "="') DO SET Battery.%%A FOR /F "tokens=* delims= " %%A IN ('WMIC/NameSpace:"\\root\WMI" Path Battery_Runtime Get EstimatedRuntime/Format:list ^| FIND "="') DO SET Battery.%%A FOR /F "tokens=* delims= " %%A IN ('WMIC/NameSpace:"\\root\WMI" Path BatteryFullChargedCapacity Get FullChargedCapacity/Format:list ^| FIND "="') DO SET Battery.%%A :: Calculate runtime left and capacity SET /A Battery.EstimatedRuntime = ( %Battery.EstimatedRuntime% + 30 ) / 60 SET /A Battery.RemainingCapacity = ( %Battery.RemainingCapacity%00 + %Battery.FullChargedCapacity% / 2 ) / %Battery.FullChargedCapacity% :: Display results IF /I "%Battery.PowerOnline%"=="TRUE" ( ECHO Now working on mains power ECHO Battery %Battery.RemainingCapacity%%% charged ) ELSE ( ECHO Estimated remaining runtime %Battery.EstimatedRuntime% minutes ECHO Remaining capacity %Battery.RemainingCapacity%%% ) pause GOTO:EOF
May 10th, 2010 11:00am

Hi, Since it is a script related question, I suggest you discuss in the following forum. The Official Scripting Guys Forum!Arthur Xie - MSFT
Free Windows Admin Tool Kit Click here and download it now
May 11th, 2010 11:24am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics