Back to Windows_ERR_HELP
#!/bin/mksh
#SHELL SCRIPT TO OPEN notepad.exe AT WINDOWS WHEN LAPTOP POWER BATTERY IS 98% OR 25%
#REMOVE OR ADD PLUG AT LAPTOP TO REMOVE THIS ALERT MESSAGE PROVIDED USING notepad.exe.
POWEROFF=1
#WMIC.exe Path Win32_Battery Get BatteryStatus => 1 => LAPTOP POWER IS OFF
#WMIC.exe Path Win32_Battery Get BatteryStatus => 2 => LAPTOP POWER IS ON
POWERON=2
SLEEPTIME=10
unset -f HANDLETASKMGR
HANDLETASKMGR ()
{
	if [ "" = "$BATTERY_PERCENTAGE_AVAILABLE" ]
	then
		BATTERY_PERCENTAGE_AVAILABLE=$(/cygdrive/c/WINDOWS/System32/Wbem/WMIC.exe Path Win32_Battery Get EstimatedChargeRemaining 2>&1 |\
		/usr/bin/awk '{
			if( 2 == NR )
			{
				printf( "%d", substr( $1, 1, length( $0) -1 ) );
			}
		}')
	fi
	if [ $BATTERY_PERCENTAGE_AVAILABLE -le 25 ]
	then
		CURRENTPOWERSTAT=$(/cygdrive/c/WINDOWS/System32/Wbem/WMIC.exe Path Win32_Battery Get BatteryStatus 2>&1 |\
		/usr/bin/awk '{
			if( 2 == NR )
			{
				printf( "%d", $1);
			}
		}')
		/cygdrive/c/Windows/System32/wbem/WMIC.exe Path Win32_Battery Get BatteryStatus 2>&1 | /usr/bin/tr -d "\r" | /usr/bin/grep 2 >/dev/null 2>&1
		Ret=$?
		if [ 0 -eq $Ret ]
		then
			export POWER="ON"
		else
			export POWER="OFF"
		fi
		if [ $POWEROFF -eq $CURRENTPOWERSTAT ]
		then
			/cygdrive/c/WINDOWS/system32/taskkill.exe /f /im notepad.exe >/dev/null 2>&1
			/cygdrive/c/WINDOWS/System32/Wbem/WMIC.exe Path Win32_Battery Get EstimatedChargeRemaining 2>&1 |\
			/usr/bin/tr -d "\r" 2>&1 |\
			/usr/bin/awk '2 == NR { printf( "ADD    POWER PLUG\nBATTERY PERCENTAGE_01 %s%%\nPOWER IS %s", $1, ENVIRON["POWER"] ); }' >/home/murugesan_openssl/PowerPercentage.txt
			/cygdrive/c/WINDOWS/system32/cmd.exe /c "start /max C:\\Windows\\System32\\notepad.exe C:\\cygwin\\home\\murugesan_openssl\\PowerPercentage.txt" >/dev/null 2>&1 &
			/usr/bin/touch /tmp/TASKMGR.txt
			SLEEPTIME=10
		else
			if [ -f /tmp/TASKMGR.txt ]
			then
				/usr/bin/rm /tmp/TASKMGR.txt
			fi
			/cygdrive/c/WINDOWS/system32/taskkill.exe /f /im notepad.exe >/dev/null 2>&1
			SLEEPTIME=60
			return 1
		fi
	elif [ $BATTERY_PERCENTAGE_AVAILABLE -ge 98 ]
	then
		CURRENTPOWERSTAT=$(/cygdrive/c/WINDOWS/System32/Wbem/WMIC.exe Path Win32_Battery Get BatteryStatus 2>&1 |\
		/usr/bin/awk '{
			if( 2 == NR )
			{
				printf( "%d", $1);
			}
		}')
		/cygdrive/c/Windows/System32/wbem/WMIC.exe Path Win32_Battery Get BatteryStatus 2>&1 | /usr/bin/tr -d "\r" | /usr/bin/grep 2 >/dev/null 2>&1
		Ret=$?
		if [ 0 -eq $Ret ]
		then
			export POWER="ON"
		else
			export POWER="OFF"
		fi
		if [ $CURRENTPOWERSTAT -eq $POWERON ]
		then
			/cygdrive/c/WINDOWS/system32/taskkill.exe /f /im notepad.exe >/dev/null 2>&1
			/cygdrive/c/WINDOWS/System32/Wbem/WMIC.exe Path Win32_Battery Get EstimatedChargeRemaining 2>&1 |\
			/usr/bin/tr -d "\r" | /usr/bin/awk '2 == NR { printf( "REMOVE POWER PLUG\nBATTERY PERCENTAGE_02 %s%%\nPOWER IS %s", $1, ENVIRON["POWER"] ); }' >/home/murugesan_openssl/PowerPercentage.txt
			/cygdrive/c/WINDOWS/system32/cmd.exe /c "start /max C:\\Windows\\System32\\notepad.exe C:\\cygwin\\home\\murugesan_openssl\\PowerPercentage.txt" >/dev/null 2>&1 &
			/usr/bin/touch /tmp/TASKMGR.txt
			SLEEPTIME=10
		else
			if [ -f /tmp/TASKMGR.txt ]
			then
				/usr/bin/rm /tmp/TASKMGR.txt
			fi
			/cygdrive/c/WINDOWS/system32/taskkill.exe /f /im notepad.exe >/dev/null 2>&1
			SLEEPTIME=60
			return 1
		fi
	fi
}
while [ 1 ]
do
	BATTERY_PERCENTAGE_AVAILABLE=$(/cygdrive/c/Windows/System32/wbem/WMIC.exe Path Win32_Battery Get EstimatedChargeRemaining 2>&1 |\
	/usr/bin/awk '{
		if( 2 == NR )
		{
			printf( "%d", $1);
		}
	}')
	if [ $BATTERY_PERCENTAGE_AVAILABLE -le 20 ]
	then
		CURRENTPOWERSTAT=$(/cygdrive/c/WINDOWS/System32/Wbem/WMIC.exe Path Win32_Battery Get BatteryStatus 2>&1 |\
		/usr/bin/awk '{
			if( 2 == NR )
			{
				printf( "%d", $1);
			}
		}')
		if [ $CURRENTPOWERSTAT -eq $POWEROFF ]
		then
			/cygdrive/c/Windows/System32/wbem/WMIC.exe Path Win32_Battery Get BatteryStatus 2>&1 | /usr/bin/tr -d "\r" | /usr/bin/grep 2 >/dev/null 2>&1
			Ret=$?
			if [ 0 -eq $Ret ]
			then
				export POWER="ON"
			else
				export POWER="OFF"
			fi
			/cygdrive/c/WINDOWS/system32/taskkill.exe /f /im notepad.exe >/dev/null 2>&1
			/cygdrive/c/WINDOWS/System32/Wbem/WMIC.exe Path Win32_Battery Get EstimatedChargeRemaining 2>&1 | /usr/bin/tr -d "\r" | /usr/bin/awk '2 == NR { printf( "BATTERY PERCENTAGE_03 %s%%\nPOWER IS %s\n", $1, ENVIRON["POWER"] ); }' >/home/murugesan_openssl/PowerPercentage.txt
			/cygdrive/c/WINDOWS/system32/cmd.exe /c "start /max C:\\Windows\\System32\\notepad.exe C:\\cygwin\\home\\murugesan_openssl\\PowerPercentage.txt" >/dev/null 2>&1 &
			/usr/bin/touch /tmp/TASKMGR.txt
			SLEEPTIME=10
		else
			if [ -f /tmp/TASKMGR.txt ]
			then
				/usr/bin/rm /tmp/TASKMGR.txt
			fi
			/cygdrive/c/WINDOWS/system32/taskkill.exe /f /im notepad.exe >/dev/null 2>&1 &
			SLEEPTIME=60
			continue
		fi
	elif [ $BATTERY_PERCENTAGE_AVAILABLE -ge 99 ]
	then
		CURRENTPOWERSTAT=$(/cygdrive/c/WINDOWS/System32/Wbem/WMIC.exe Path Win32_Battery Get BatteryStatus 2>&1 |\
		/usr/bin/awk '{
			if( 2 == NR )
			{
				printf( "%d", $1);
			}
		}')
		if [ $CURRENTPOWERSTAT -eq $POWERON ]
		then
			/cygdrive/c/Windows/System32/wbem/WMIC.exe Path Win32_Battery Get BatteryStatus 2>&1 | /usr/bin/tr -d "\r" | /usr/bin/grep 2 >/dev/null 2>&1
			Ret=$?
			if [ 0 -eq $Ret ]
			then
				export POWER="ON"
			else
				export POWER="OFF"
			fi
			/cygdrive/c/WINDOWS/system32/taskkill.exe /f /im notepad.exe >/dev/null 2>&1
			/cygdrive/c/WINDOWS/System32/Wbem/WMIC.exe Path Win32_Battery Get EstimatedChargeRemaining 2>&1 | /usr/bin/tr -d "\r" | /usr/bin/awk '2 == NR { printf( "BATTERY PERCENTAGE_04 %s%%\nPOWER IS %s\n", $1, ENVIRON["POWER"] ); }' >/home/murugesan_openssl/PowerPercentage.txt
			/cygdrive/c/WINDOWS/system32/cmd.exe /c "start /max C:\\Windows\\System32\\notepad.exe C:\\cygwin\\home\\murugesan_openssl\\PowerPercentage.txt" >/dev/null 2>&1 &
			/usr/bin/touch /tmp/TASKMGR.txt
			SLEEPTIME=10
		else
			if [ -f /tmp/TASKMGR.txt ]
			then
				/usr/bin/rm /tmp/TASKMGR.txt
			fi
			/cygdrive/c/WINDOWS/system32/taskkill.exe /f /im notepad.exe >/dev/null 2>&1 &
			SLEEPTIME=60
			continue
		fi
	fi
	for ONSECOND in {1..5}
	do
		HANDLETASKMGR
		Ret=$?
		if [ 1 -eq $Ret ]
		then
			break
		fi
		if [ -d /cygdrive/c/Users/myDB/AppData/Local/Adobe ]
		then
			/usr/bin/rm -rf /cygdrive/c/Users/myDB/AppData/Local/Adobe >/dev/null 2>&1 &
		fi
		if [ -f /cygdrive/c/Users/myDB/AppData/Local/PUTTY.RND ]
		then
			/usr/bin/rm -f /cygdrive/c/Users/myDB/AppData/Local/PUTTY.RND >/dev/null 2>&1 &
		fi
		/cygdrive/c/Windows/System32/reg.exe query "HKCU\Software\Microsoft\CTF\LangBar" 2>&1 |\
		/usr/bin/tr -d "\r" 2>&1 |\
		/usr/bin/grep "ShowStatus" 2>&1 |\
		/usr/bin/grep "0x4" >/dev/null 2>&1
		Ret=$?
		if [ 0 -ne $Ret ]
		then
			/cygdrive/c/Windows/System32/reg.exe add "HKCU\Software\Microsoft\CTF\LangBar" /f /v ShowStatus /t REG_DWORD /d 4 >/dev/null 2>&1
			echo Yes | /cygdrive/c/Windows/System32/reg.exe add "HKCU\Software\Microsoft\CTF\LangBar" /f /v ShowStatus /t REG_DWORD /d 4 >/dev/null 2>&1
		fi
		/usr/bin/sleep $SLEEPTIME
	done
done