VBScript that changes CachedLogonsCount value in registry

Posted on 2005-03-17
Medium Priority
Last Modified: 2008-02-01

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.
Question by:dan29
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

jkorz earned 1000 total points
ID: 13568545
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


Author Comment

ID: 13646632

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month13 days, 5 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question