Script to invoke the current user’s screen saver

Thanks to The Scripting Dude for this script, which I made a small correction to. Save it as a .vbs file and run it to invoke the screen saver for the currently logged on user.

 

' This script runs the screen saver associated to the current user.

Set oShell = WScript.CreateObject ("WSCript.shell")
Set WMIService = GetObject("winmgmts:")
Set colComputerSystem = WMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem")

For Each objProperty in colComputerSystem
strUsername = replace(objProperty.UserName, "\","\\")
Next

strWQL = "SELECT * FROM Win32_Desktop WHERE Name='" & strUserName & "'"
Set colDesktopItems = WMIService.ExecQuery(strWQL)

For Each objDesktopItem in colDesktopItems
oShell.run objDesktopItem.ScreenSaverExecutable
Next

' This will show you who is logged on, if you are interested:
' msgbox(strUserName)