Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo OFF
- cls
- setlocal EnableDelayedExpansion
- goto :Main
- This script will monitor your PC when someone logs on.
- Add Scheduled Task.
- schtasks /Create /SC ONLOGON /TR "%windir%\system32\notepad.exe" /TN "\Monitor"
- schtasks /Delete /TN "\Monitor"
- :Main
- REM Configuration.
- set "PAUSES=0"
- set "SNAPS=3"
- set "WAIT=5"
- set /a "AUDIOTIME=WAIT*SNAPS"
- set /a "AUDIOTIME=AUDIOTIME-WAIT"
- set "CAM=Webcam name"
- set "MIC=Microphone name"
- set "OPTBEG=-hide_banner -nostats -loglevel 0 -y"
- set "OPTEND="
- set "DEST=%APPDATA%\Monitor"
- REM Tools.
- set "FFMPEG=%PROGRAMFILES%\ffmpeg\bin\ffmpeg.exe"
- set "ZIP=%PROGRAMFILES%\7-Zip\7z.exe"
- REM Create folder from date-time.
- ::rd /S /Q "%DEST%"
- if not exist "%DEST%" (mkdir "%DEST%")
- set DT=%DATE:~6,4%-%DATE:~3,2%-%DATE:~0,2%__%TIME:~0,2%-%TIME:~3,2%-%TIME:~6,2%
- set DT=%DT: =0%
- mkdir "%DEST%\%DT%"
- REM Record audio.
- start "" "%FFMPEG%" %OPTBEG% -f dshow -i audio="%MIC%" -t %AUDIOTIME% "%DEST%\%DT%\startup.mp3"
- REM Snap images.
- for /L %%i in (1, 1, %SNAPS%) do (
- set "FORMATTEDVALUE=000000%%i"
- timeout %WAIT% /nobreak >nul
- set "DTLOOP=!DATE:~6,4!-!DATE:~3,2!-!DATE:~0,2!_!TIME:~0,2!-!TIME:~3,2!-!TIME:~6,2!"
- set "DTLOOP=!DTLOOP: =0!"
- set "DTLOOP=!DTLOOP:_= !"
- "%FFMPEG%" %OPTBEG% -f gdigrab -i desktop -frames 1 "%DEST%\%DT%\!FORMATTEDVALUE:~-4! !DTLOOP! Screen.jpg"
- "%FFMPEG%" %OPTBEG% -f dshow -i video="%CAM%" -vframes 1 "%DEST%\%DT%\!FORMATTEDVALUE:~-4! !DTLOOP! Cam.png"
- )
- REM Compress.
- "%ZIP%" a "%DEST%\%DT%.7z" -y "%DEST%\%DT%" -pPA55W0RD
- if %ERRORLEVEL% NEQ 0 (del /Q "%DEST%\%DT%.7z")
- REM Clean uncompressed.
- if exist "%DEST%\%DT%.7z" (rd /S /Q "%DEST%\%DT%")
- :Purge
- REM Is the folder greater than 1GB?
- for /F "tokens=*" %%a in ('"dir "%DEST%" /s /-c /a | find "bytes" | find /v "free""') do set XSUMMARY=%%a
- for /F "tokens=1,2 delims=)" %%a in ("%XSUMMARY%") do set XSIZE=%%b
- set XSIZE=%XSIZE:bytes=%
- set XSIZE=%XSIZE: =%
- REM 1GB = 1073741824 bytes
- if %XSIZE% GTR 1073741824 (
- for /f "delims=" %%a in ('dir "%DEST%\*" /t:c /o:-d /b') do set LASTITEM=%%a
- del /Q "%DEST%\!LASTITEM!" || rd /s /q "%DEST%\!LASTITEM!"
- goto :Purge
- )
- if %PAUSES% EQU 1 (pause)
- endlocal
- exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement