Advertisement
Guest User

StandbyChecker

a guest
Mar 21st, 2019
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.40 KB | None | 0 0
  1. @Echo Off
  2. SetLocal EnableDelayedExpansion
  3. Set $COUNTE1=0
  4. Set $ONETIMECOUNTER=0
  5. Set $D=E
  6.  
  7. Set $COMPARE="Device is in ACTIVE or IDLE mode"
  8.  
  9.  
  10. :BackLog
  11.  
  12. For /F "Delims=" %%I In ('smartctl.exe -n standby %$D%:') Do Set $RESULTA=%%~I
  13.  
  14. :: Убираем кавычки
  15. Set $RESULTA="%$RESULTA%"
  16.  
  17.  
  18. If %$ONETIMECOUNTER%==0 (
  19.     echo %date% %time% %$RESULTA%
  20.     echo.
  21.     If %$RESULTA%==%$COMPARE% (
  22.         echo.>> StandbyLog_%$D%.txt
  23.         echo Bat file is started:>> StandbyLog_%$D%.txt
  24.         echo %date% %time%   %$D% - Disk is ACTIVE>> StandbyLog_%$D%.txt
  25.         echo.>> StandbyLog_%$D%.txt
  26.         echo Log:>> StandbyLog_%$D%.txt
  27.         If %$RESULTA%==%$COMPARE% (
  28.             set $COUNTE1=0
  29.         )
  30.     ) else (
  31.         echo.>> StandbyLog_%$D%.txt
  32.         echo Bat file is started:>> StandbyLog_%$D%.txt
  33.         echo %date% %time%   %$D% - Disk is STANDBY>> StandbyLog_%$D%.txt
  34.         echo.>> StandbyLog_%$D%.txt
  35.         echo Log:>> StandbyLog_%$D%.txt
  36.         If not %$RESULTA%==%$COMPARE% (
  37.             set $COUNTE1=1
  38.         )
  39.     )
  40.     set $ONETIMECOUNTER=1
  41. )
  42.  
  43. If %$COUNTE1%==1 (
  44.     If %$RESULTA%==%$COMPARE% (
  45.         echo %date% %time% %$RESULTA%
  46.         echo %date% %time%   %$D% - Disk is ACTIVE>> StandbyLog_%$D%.txt
  47.         set $COUNTE1=0
  48.     )
  49. )
  50.  
  51. If %$COUNTE1%==0 (
  52.     If not %$RESULTA%==%$COMPARE% (
  53.         echo %date% %time% %$RESULTA%
  54.         echo %date% %time%   %$D% - Disk is STANDBY>> StandbyLog_%$D%.txt
  55.         echo.>> StandbyLog_%$D%.txt
  56.         set $COUNTE1=1
  57.     )
  58. )
  59.  
  60. TIMEOUT /T 1 /NOBREAK >nul
  61.  
  62. goto :BackLog
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement