Top
JohnKlann / scripting  / How To: Change a registry key with VBS + User Input Screensaver Timeout Duration

How To: Change a registry key with VBS + User Input Screensaver Timeout Duration

So have you ever been working on a work computer and the screen saver timeout period is 15 minutes? Then you go to change it and the properties box is grayed out? Well there is good news you can change this through windows registries. The following vbs script does just that for Windows XP, Windows Vista, and Windows 7.

Now windows uses time in seconds. So 3600 seconds equals 1 hour. This script uses an input box to allow the time to be adjusted based on your preference.

All you have to do is copy and paste the code into notepad and save as screensaver.vbs That’s it double click the file, it will prompt you for a duration click ok and now your screensaver timeout duration has now been adjusted. You can look at the screensaver properties and you will see the change. Another option is to view it in regedit if you feel so inclined.

A video demonstration will be provided shortly.

'System variables
Dim objShell, RegLocate, RegLocate1
Set objShell = WScript.CreateObject("WScript.Shell")
'Creating the input box
strUserInput = InputBox( "Please enter Screen saver duration time out (3600 = 1 Hr) Default value is 900:" )

'Fucntion to check for vailid entries
Function InputCheck(strUserInput)
'checks to make sure that the input field is not blank
if strUserInput =0 then
'warning message box
MsgBox "Please enter a duration"
strUserInput = InputBox( "Please enter Screen saver duration time out (3600 = 1 Hr) Default value is 900:" )
End If
'checks to make sure that a negative number was not inserted
if strUserInput  'warning message box
MsgBox "Please enter a valid duration minimun value of 900s = 15 mintues"
strUserInput = InputBox( "Please enter Screen saver duration time out (3600 = 1 Hr) Default value is 900:" )
End If
'checks to make sure that the input is more than 900 seconds
if strUserInput  'warning message box
MsgBox "Please enter a valid duration minimun value of 900s = 15 mintues"
strUserInput = InputBox( "Please enter Screen saver duration time out (3600 = 1 Hr) Default value is 900:" )
End If
'if it passes all other input checks this actually submits the change and updates the registry
if strUserInput >899 then
On Error Resume Next
'selects the registry key to change
RegLocate = "HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Control Panel\Desktop\ScreenSaveTimeOut"
'writes the registry Value and key with the registry value type
objShell.RegWrite RegLocate,strUserInput,"REG_SZ"
'Lets you know it worked
MsgBox "Your Duration has Changed Successfully"
'Ends the script
WScript.Quit
End if
End Function
'Calls the function to run the script
Dim result
result = InputCheck(strUSerInput)

Submit your review
1
2
3
4
5
Submit
     
Cancel

Create your own review

Average rating:  
 0 reviews