@Echo off Setlocal ENABLEDELAYEDEXPANSION Pushd %~dp0 Set Out=Call :Writeln goto :Main :Writeln Echo %* TimeOutput "Date:dddd, mmmm dd" "th" " @ " "Time:hh:mm am/pm - " "%*" >> IsEncoding.log goto :Eof :FindCPULevel process | find "encoder" > ProcessLevel.txt For /f "Tokens=5 Delims= " %%a in (ProcessLevel.txt) do Set CPULevel=%%a If "%CPULevel%"=="" ( %Out% Encoder not loaded. "Full Auto.bat" ) Else ( If "%CPULevel%" GTR "10" ( %Out% Encoder is active at %CpuLevel% CPU usage ) else ( %Out% Encoder is not active. "Full Auto.bat" ) ) Goto :Eof :Main Call :FindCPULevel goto :Eof ++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++ #!/usr/bin/perl $ProcessName = "Encoder\.exe"; $ProcessorLevel = -1; $Time=localtime(time); $NextFile="\"Full Auto.bat\""; sub NotLoaded{ print ("$Time - $ProcessName not loaded. Starting new batch.\n"); print LOGFILE "$Time - $ProcessName not loaded. Starting new batch.\n"; system($NextFile); } sub DoneEncoding{ print ("$Time - $ProcessName is complete. Starting next batch.\n"); print LOGFILE "$Time - $ProcessName is complete. Starting next batch.\n"; system("$NextFile"); } sub Encoding{ print ("$Time - $ProcessName is running at a value of $ProcessorLevel\n"); print LOGFILE "$Time - $ProcessName is running at a value of $ProcessorLevel\n"; } system("process > ProcessLevel.txt"); open(LOGFILE,">>IsEncoding.log"); open(PROCESSLEVEL,") {if ($_ =~ m/$ProcessName/i) { @ProcessArray = split(/\s+/,$_); $ProcessorLevel = $ProcessArray[5]; } } if ($ProcessorLevel < 0) {NotLoaded;} elsif ($ProcessorLevel < 5) {DoneEncoding} else {Encoding;} close(LOGFILE); close(PROCESSLEVEL);