VBScript that changes CachedLogonsCount value in registry
Posted on 2005-03-17
I am quite the novice at creating vbscripts, and I have been experimenting with them lately to get them to do very basic things. The latest script that I have created is changing the cached logons count value under the HKLM hive of the registry. I have tried comparing my script to others that modify registry values, and I have been unsuccessfull at getting my script to work. The following is the contents of the script:
HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
ParentKey = "SOFTWARE\Microsoft\WindowsNT\CurrentVersion"
strKeyPath = "SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon"
strValueName = "cachedlogonscount"
strData = "50"
objReg.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strData
I do not receive a script error when running this script, it appears as if it works but when I go back into the registry the value has not changed. If someone could give me some advice as to what I am doing wrong, please let me know.