Q. How can a script display the logged on user's screen saver and wallpaper settings?

In tip 10732, we used a script to alter a user's screen saver and wallpaper settings.

I have scripted WPSS.BAT to display the logged on user's screen saver and wallpaper settings without using the registry.

The syntax for using WPSS.BAT is:

WPSS

A sample output might look like:

Name: JSIINC\Jerry
Screen Saver Active: True
Screen Saver Executable: C:\WINDOWS\XEROXV~1.SCR
Screen Saver Secure: True
Screen Saver Timeout: 600
Wallpaper: C:\WINDOWS\BGInfo.bmp
Wallpaper Stretched: True
Wallpaper Tiled: False
WPSS.BAT contains:
@echo off
setlocal EnableDelayedExpansion
if exist "%TEMP%\WPSS.VBS" goto :doit
@echo.On Error Resume Next>"%TEMP%\WPSS.VBS"
@echo.strComputer = ".">>"%TEMP%\WPSS.VBS"
@echo.Set objWMIService = GetObject("winmgmts:" _>>"%TEMP%\WPSS.VBS"
@echo.    ^& "\{impersonationLevel=impersonate\}!\\" ^& strComputer ^& "\root\cimv2")>>"%TEMP%\WPSS.VBS"
@echo.Set colItems = objWMIService.ExecQuery("Select * from Win32_Desktop")>>"%TEMP%\WPSS.VBS"
@echo.For Each objItem in colItems>>"%TEMP%\WPSS.VBS"
@echo.    Wscript.Echo "Name: " ^& objItem.Name>>"%TEMP%\WPSS.VBS"
@echo.    Wscript.Echo "Screen Saver Active: " ^& objItem.ScreenSaverActive>>"%TEMP%\WPSS.VBS"
@echo.    Wscript.Echo "Screen Saver Executable: " ^& objItem.ScreenSaverExecutable>>"%TEMP%\WPSS.VBS"
@echo.    Wscript.Echo "Screen Saver Secure: " ^& objItem.ScreenSaverSecure>>"%TEMP%\WPSS.VBS"
@echo.    Wscript.Echo "Screen Saver Timeout: " ^& objItem.ScreenSaverTimeout>>"%TEMP%\WPSS.VBS"
@echo.    Wscript.Echo "Wallpaper: " ^& objItem.Wallpaper>>"%TEMP%\WPSS.VBS"
@echo.    Wscript.Echo "Wallpaper Stretched: " ^& objItem.WallpaperStretched>>"%TEMP%\WPSS.VBS"
@echo.    Wscript.Echo "Wallpaper Tiled: " ^& objItem.WallpaperTiled>>"%TEMP%\WPSS.VBS"
@echo.Next>>"%TEMP%\WPSS.VBS"
:doit
set OK=N
for /f "Tokens=1* Delims=:" %%s in ('cscript //nologo "%TEMP%\WPSS.VBS"') do (
 set title=%%s
 set answer=%%t
 set answer=!answer:~1!
 if "!title!" EQU "Name" If /i "!answer!" EQU "%USERDOMAIN%\%UserName%" (
  set OK=Y
 ) ELSE (
  set OK=N
 )
 if "!OK!" EQU "Y"  @echo !title!: !answer!
)
endlocal


Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish