screen saver

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
storm97
Posts: 7
Joined: 13 Feb 2012 17:33

screen saver

#1 Post by storm97 » 18 Feb 2012 20:50

can u make a batch file open your screen saver over whatever it's doing?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: screen saver

#2 Post by foxidrive » 18 Feb 2012 21:06

Here's something I wrote several years ago to start a random screen saver. I don't have Win 7 to test it with but it still works in XP.

Code: Select all

@echo off
:: Start a random screensaver
if "%1"=="!" "Blank Screen.scr" /s & goto :EOF
set /a count=0
echo dummy>"%temp%.\scrnsaver.tmp"
for /f "delims=" %%a in (
 'dir "%systemroot%\*.scr" /s /b ^|find /i /v ".script"'
  ) do echo %%a>>"%temp%.\scrnsaver.tmp"&set /a count+=1
ping -n 1 -w %random% 127.0.0.1 >nul
ping -n 1 -w %random% 127.0.0.1 >nul
ping -n 1 -w %random% 127.0.0.1 >nul
ping -n 1 -w %random% 127.0.0.1 >nul
ping -n 1 -w %random% 127.0.0.1 >nul
set /a ssnum=1+(%random% %% %count%)
if %ssnum% GEQ %count% %0
for /f "skip=%ssnum% delims=" %%a in (
'type "%temp%.\scrnsaver.tmp"') do (
if /i "%%~nxa"=="Blank Screen.scr" %0
if /i "%%~nxa"=="scrnsave.scr" %0
start "" "%%a" /s
del "%temp%.\scrnsaver.tmp"
goto :EOF
)

Post Reply