Jump to content
Sign in to follow this  

Search text file for string, use string to edit registry entry

Recommended Posts



This is my first post in this forum, so be gentle. Here is the basic idea of what I am trying to do...

I am trying to write a script that will search through a text file on the c:\ and then take that string and make an edit to a specific registry key. I am trying to run cpuz.exe to find out the L2 cache for the specific PC. I run the exe from a batch file (would like to incorporate that into autoit) with the following line: cpuz.exe -txt=c:\mysystem

Once I have the .txt file on the client computer, I want to have a script that will search the output file for the L2 cache size. I have a attached the .txt file.





Depending on the size of the cache, I want to make the correct edit to the following registry key

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management]


For the dword value, use the corresponding value for the size of cache:

512 = 00000200

1024 = 00000400

2048 = 00000800

Any help to do this would be great.



Share this post

Link to post
Share on other sites

It's just easier getting L2CacheSize through WMI.

$objWMIService = ObjGet("winmgmts:\\.\root\CIMV2")
$WMIQuery = $objWMIService.ExecQuery("SELECT * FROM Win32_Processor")
For $item In $WMIQuery
    MsgBox(0,"L2CacheSize: ",$item.L2CacheSize)

But read this article from Microsoft.

Do not change the SecondLevelDataCache entry

Some third-party sources have erroneously reported that modifying the SecondLevelDataCache registry entry in HKEY_LOCAL_MACHINE\System\CurrentControlSet \Control\Session Manager\Memory Management can enhance system performance. The second level (L2) cache is recognized by the operating system and is fully utilized regardless of the setting of this parameter.

Share this post

Link to post
Share on other sites

Thanks for that idea. I tried it on a couple different models of PC. It worked on my PC which is a single core processor (returned 2048). However, when I ran it on a dual core machine, it returned "0" for the value.

Regardless of what these articles say, I would still like to figure out a way to automate from the text file I have attached.

Thanks. :whistle:

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this