下面是自動隨機切換鎖定屏幕畫面的批處理腳本.
因爲時間比較晚了, 關於任務計劃部分明天再貼出.
@echo off
set sid=%1
if not defined sid (goto exit)
for /f "tokens=*" %%f in ('echo %sid%') do set sid=%%~f
echo %sid% | find "S-1-5-21" > nul
if %errorlevel% neq 0 (goto exit)
set imagesPath=%2
if not defined imagesPath (goto exit)
if not exist %imagesPath% (goto exit)
pushd %cd%
cd /d "%imagesPath%"
set /a err=%errorlevel%
popd.
if %err% neq 0 (goto exit)
for /f "tokens=*" %%f in ('echo %imagesPath%') do set imagesPath=%%~f
set /a files=0
for /f "tokens=*" %%n in ('dir "%imagesPath%\*.jpg" /a-d/b/s ^| find /c /v ""') do set /a files=%%n
set /a index=0
set /a index=%random%%%files%+1
set /a cnt=0
setlocal enabledelayedexpansion
set c=
for /f "tokens=3" %%f in ('reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\SystemProtectedUserData\%sid%\AnyoneRead\LockScreen /ve') do (
set str=%%f
set c=!str:~0,1!
)
if not defined c (goto exit)
for /f "tokens=*" %%f in ('dir "!imagesPath!\*.jpg" /a-d/b/s') do (
set image=%%f
set /a cnt=!cnt!+1
if !cnt! equ !index! (goto break)
)
:break
for /f "skip=2 tokens=1" %%a in ('wmic desktopmonitor get screenwidth') do set /a width=%%a
for /f "skip=2 tokens=1" %%a in ('wmic desktopmonitor get screenheight') do set /a height=%%a
if !height! lss 999 (set height=0!height!)
del C:\ProgramData\Microsoft\Windows\SystemData\!sid!\\ReadOnly\LockScreen_!c!\LockScreen___!width!_!height!.jpg /a/f/q
mklink "C:\ProgramData\Microsoft\Windows\SystemData\!sid!\ReadOnly\LockScreen_!c!\LockScreen___!width!_!height!.jpg" "!image!"
:exit
endlocal