Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting Screen Saver Via VBS

Status
Not open for further replies.

JoCoSupport

IS-IT--Management
Dec 9, 2010
3
US
I have seen other threads, and on other forums, that people are having a hard time setting the Screen Saver via vbs. I have seen some very long and complex scripts, so thought i would share a more simplified one.


On Error Resume Next

Set f_objShell = CreateObject("WScript.Shell")

Reg_Key_Main = "HKEY_CURRENT_USER\Control Panel\Desktop\"
Reg_ScreenSaveActive = 1
Reg_ScreenSaverIsSecure = 1
Reg_ScreenSaveTimeOut = 600
Reg_SCRNSAVE_EXE = "C:\WINDOWS\system32\logon.scr"

f_objShell.RegWrite Reg_Key_Main & "ScreenSaveActive", Reg_ScreenSaveActive, "REG_SZ"
f_objShell.RegWrite Reg_Key_Main & "ScreenSaverIsSecure", Reg_ScreenSaverIsSecure, "REG_SZ"
f_objShell.RegWrite Reg_Key_Main & "ScreenSaveTimeOut", Reg_ScreenSaveTimeOut, "REG_SZ"
f_objShell.RegWrite Reg_Key_Main & "SCRNSAVE.EXE", Reg_SCRNSAVE_EXE, "REG_SZ"

Set f_objShell = Nothing
Err.Clear
On Error Goto 0


As you can see, this ignores all errors, so may need some tweaking depending on how you are using it. Change the variables as needed.

 
This might be a good one to post in the 'computer settings' area of the forum FAQ.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top