Advertisement
J2897

Monitor v0.1 - BETA

Sep 16th, 2016
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 2.15 KB | None | 0 0
  1. @echo OFF
  2. cls
  3. setlocal EnableDelayedExpansion
  4. goto :Main
  5.  
  6.     This script will monitor your PC when someone logs on.
  7.  
  8.     Add Scheduled Task.
  9.     schtasks /Create /SC ONLOGON /TR "%windir%\system32\notepad.exe" /TN "\Monitor"
  10.     schtasks /Delete /TN "\Monitor"
  11.  
  12. :Main
  13. REM Configuration.
  14. set "PAUSES=0"
  15. set "SNAPS=3"
  16. set "WAIT=5"
  17. set /a "AUDIOTIME=WAIT*SNAPS"
  18. set /a "AUDIOTIME=AUDIOTIME-WAIT"
  19. set "CAM=Webcam name"
  20. set "MIC=Microphone name"
  21. set "OPTBEG=-hide_banner -nostats -loglevel 0 -y"
  22. set "OPTEND="
  23. set "DEST=%APPDATA%\Monitor"
  24.  
  25. REM Tools.
  26. set "FFMPEG=%PROGRAMFILES%\ffmpeg\bin\ffmpeg.exe"
  27. set "ZIP=%PROGRAMFILES%\7-Zip\7z.exe"
  28.  
  29. REM Create folder from date-time.
  30. ::rd /S /Q "%DEST%"
  31. if not exist "%DEST%" (mkdir "%DEST%")
  32. set DT=%DATE:~6,4%-%DATE:~3,2%-%DATE:~0,2%__%TIME:~0,2%-%TIME:~3,2%-%TIME:~6,2%
  33. set DT=%DT: =0%
  34. mkdir "%DEST%\%DT%"
  35.  
  36. REM Record audio.
  37. start "" "%FFMPEG%" %OPTBEG% -f dshow -i audio="%MIC%" -t %AUDIOTIME% "%DEST%\%DT%\startup.mp3"
  38.  
  39. REM Snap images.
  40. for /L %%i in (1, 1, %SNAPS%) do (
  41.     set "FORMATTEDVALUE=000000%%i"
  42.     timeout %WAIT% /nobreak >nul
  43.     set "DTLOOP=!DATE:~6,4!-!DATE:~3,2!-!DATE:~0,2!_!TIME:~0,2!-!TIME:~3,2!-!TIME:~6,2!"
  44.     set "DTLOOP=!DTLOOP: =0!"
  45.     set "DTLOOP=!DTLOOP:_= !"
  46.     "%FFMPEG%" %OPTBEG% -f gdigrab -i desktop -frames 1 "%DEST%\%DT%\!FORMATTEDVALUE:~-4! !DTLOOP! Screen.jpg"
  47.     "%FFMPEG%" %OPTBEG% -f dshow -i video="%CAM%" -vframes 1 "%DEST%\%DT%\!FORMATTEDVALUE:~-4! !DTLOOP! Cam.png"
  48. )
  49.  
  50. REM Compress.
  51. "%ZIP%" a "%DEST%\%DT%.7z" -y "%DEST%\%DT%" -pPA55W0RD
  52. if %ERRORLEVEL% NEQ 0 (del /Q "%DEST%\%DT%.7z")
  53.  
  54. REM Clean uncompressed.
  55. if exist "%DEST%\%DT%.7z" (rd /S /Q "%DEST%\%DT%")
  56.  
  57. :Purge
  58. REM Is the folder greater than 1GB?
  59. for /F "tokens=*" %%a in ('"dir "%DEST%" /s /-c /a | find "bytes" | find /v "free""') do set XSUMMARY=%%a
  60. for /F "tokens=1,2 delims=)" %%a in ("%XSUMMARY%") do set XSIZE=%%b
  61. set XSIZE=%XSIZE:bytes=%
  62. set XSIZE=%XSIZE: =%
  63. REM 1GB = 1073741824 bytes
  64. if %XSIZE% GTR 1073741824 (
  65.     for /f "delims=" %%a in ('dir "%DEST%\*" /t:c /o:-d /b') do set LASTITEM=%%a
  66.     del /Q "%DEST%\!LASTITEM!" || rd /s /q "%DEST%\!LASTITEM!"
  67.     goto :Purge
  68. )
  69.  
  70. if %PAUSES% EQU 1 (pause)
  71. endlocal
  72. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement