Complete script | Mining University

Complete script

A few weeks ago I was doing some work with Vulcan's Chronos scheduler and became increasingly frustrated, doing tasks that took a few minutes to complete, but which had no alert to let me know when it was done.  This wasn't the first time I have wished for an alert from a program and it finally hit me that if I was looking for this script then someone else might be also.  This script is the result of that realization. 
Prior to writing this script I had very little knowledge of the Microsoft batch file or even c-shell commands.  It took a while to get the syntax correct, and it isn't optimized for performance or simplicity but it does work and it wasn't all that hard.

The premise of the script is that it monitors the cpu usage of the computer.  If the cpu usage drops below five percent for five seconds in a row the script plays the Windows 'tada' sound.  The script was originally written for Windows 7.  I don't know how it will perform on other platforms. 
Good luck, I hope this helps you as much as it helped me.

Complete Script

  1. Copy the text below
  2. Paste in a text file
  3. Rename the file 'complete.bat'
  4. Save file
To run:
  1. Double click on the complete.bat file
  2. When your cpu performance drops below five percent for five seconds in a row the windows 'tada' sound will play

@ echo off
: reset
set continue=0
: cpu_working
set continue_previous=%continue%
typeperf "\processor(_total)\%% processor time" -sc 1 > parameter.txt
for /F "eol=E tokens=3 skip=2 delims=,." %%i in (parameter.txt) do (
  if /i %%~i leq 5 set /a continue+=1)
if %continue_previous% == %continue% goto reset
if /i %continue% lss 5 goto cpu_working
del parameter.txt
timeout /t 3
taskkill /im wmplayer.exe
echo %time%

No comments:

Post a Comment