[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 677
  • Last Modified:

VBScript that changes CachedLogonsCount value in registry


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:

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.
1 Solution
I believe that the problem you are having isn't with your script, I tried it out and it worked fine... with a non-windows registry key

I am pretty sure that the winlogon key is protected from being edited with vbs for security reasons

Make a bogus key and use your script to update it and you will see what I mean

if you feel inclined to do this with vb instead of vbs, you may want to try microsoft's regop class, I use it in the program I maintain and it works like a charm

dan29Author Commented:

Thank you for your advice.  I believe you are correct about the winlogon key, as well as for most keys under the HKLM hive.  I'll go ahead and try to use the RegOp class, although this may be beyond the level that I am at with VBscript.

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now