-
Notifications
You must be signed in to change notification settings - Fork 23
/
cpuLoadGraphic.cmd
65 lines (65 loc) · 2.47 KB
/
cpuLoadGraphic.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
:: BEGIN SCRIPT :::::::::::::::::::::::::::::::::::::::::::::::::::::
:: cpuLoadGraphic.cmd
:: From the desk of Frank P. Westlake, 2013-01-30
:: Written on Windows 8.
:: This script requires "%SystemRoot%\System32\wbem\WMIC.exe".
:: Some versions of WMIC do not provide useful CPU load data.
:: If you have a hex editor set mark chracter to hex DB.
@Echo OFF&SetLocal EnableExtensions EnableDelayedExpansion
:User_Configuration ****************************************************
REM These values may be changed while the script is active.
Set "mark=Û" % REM Set this to your desired graphic. %
Set "low=10" % REM Zero to "low" is the low range. %
Set "high=50" % REM "low" to "high" is the mid range. %
% REM "high" to 100 is the high range. %
Set "lowColor=0A" % REM Low range color. %
Set "midColor=0E" % REM Mid range color. %
Set "highColor=0C" % REM High range color. %
Set "reConfig=60" % REM Read this configuration every x seconds. %
Set "codePage=437" % REM Code page. %
REM END USER CONFIGURATION *********************************************
REM Continue if just starting, go to :EOF if CALLed.
If "%0" EQU ":User_Configuration" Goto :EOF
If NOT EXIST "%SystemRoot%\System32\wbem\WMIC.exe" (
Echo This script requires "%SystemRoot%\System32\wbem\WMIC.exe".
Goto :EOF
)>&2
If "%*" NEQ "/start" (
START "CPU LOAD" CMD /c%~f0 /start
Exit
Goto :EOF
)
CHCP %codePage% >NUL:
MODE CON lines=1 cols=107
SetLocal EnableExtensions EnableDelayedExpansion
Set "bar="
Set "sp="
For /L %%i in (1,1,100) Do (
Set "bar=!bar!!mark!"
Set "sp=!sp! "
)
:: Get a carriage return character.
For /F %%a in ('COPY /Z "%~dpf0" NUL:') Do Set "CR=%%a"
Set "iteration=0"
For /L %%i in (1,0,2) Do (
For /F "tokens=2 delims==" %%a in ('wmic cpu get loadpercentage /format:list^|Find "="') Do (
Set /A "load=%%a"
Set "line=!load!%% "
TITLE !line!
If !load! LSS !low! (
Color !lowColor!
) Else If !load! LSS !high! (
Color !midColor!
) Else (
Color !highColor!
)
For %%b in (!load!) Do Set /P "=!line:~0,4! !bar:~0,%%b!!sp:~%%b! !CR!"<NUL:
)
Set /A "iteration+=1, remainder=iteration %% reConfig"
If !remainder! EQU 0 (
Set "iteration=0"
Call :User_Configuration
)
)
Goto :EOF
:: END SCRIPT ::::::::::::::::::::::::::::::::::::::::::::::::::::