Sunday 13 January 2013

Disabling the screensaver on an execution PC

More useful automation code

'Author: Mohamed Ali & Patrick Tsang
'Date: 11/03/2010

Const HKEY_CURRENT_USER = &H80000001
strComputer = "."


'Create Key
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")

strKeyPath = "Software\Policies\Microsoft\Windows\Control Panel\Desktop"
oReg.CreateKey HKEY_CURRENT_USER,strKeyPath
'Create String
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")
strSSActiveNameValue = "ScreenSaveActive"
strSSActiveValue = "0"
strSSIsSecureNameValue = "ScreenSaverIsSecure"
strSSIsSecureValue = "0"
strSSTimeOutNameValue = "ScreenSaveTimeOut"
strSSTimeOutValue = "0"

oReg.SetStringValue HKEY_CURRENT_USER,strKeyPath,strSSActiveNameValue,strSSActiveValue
oReg.SetStringValue HKEY_CURRENT_USER,strKeyPath,strSSIsSecureNameValue,strSSIsSecureValue
oReg.SetStringValue HKEY_CURRENT_USER,strKeyPath,strSSTimeOutNameValue,strSSTimeOutValue

'Msgbox "Registry Updated: Screen Saver is now disabled."

No comments:

Post a Comment