A1VBCode Forums

Setting Screensaver with VBscript


http://a1vbcode.com/vbforums/Topic25490.aspx

By Mobius - 8/1/2008

I'm trying to develop a script that will check to see if a screensaver is enabled, and if not, set it to the default Windows XP screensaver. So far, I've assembled quite a conglomeration of code using different sources, and I've worked out several errors, but this particular one I can't quite get past:



Option Explicit

Dim HKEY_CURRENT_USER

HKEY_CURRENT_USER= "&H80000001"

Dim objReg, strComputer, strKeyPath, strValue, ValueName

'strComputer = "."

strKeyPath = "Control Panel\Desktop"

Set objReg = GetObject("winmgmts:\\.\root\default:StdRegProv")

'***set variable strkeypath***
strKeyPath = "Control Panel\Desktop"

'***set variable valuename***
ValueName = "ScreenSaveActive"

'***set variable strvalue***
strValue = "1"

objReg.CreateKey HKEY_CURRENT_USER, strKeyPath, ValueName




That last line is where I get a Type Mismatch error. Any ideas?
By dannyrose12 - 1/28/2011

I **** settled point 1 of my less projection. I am able to set the screensaver to whatsoever I deprivation, forward the record is in sys32. Now, I would equivalent to only run this playscript if no screensaver is currently set. Does anyone jazz how to verify for that?