Jump to content
Sign in to follow this  

My way works... But I know there is a better way.

Recommended Posts

I needed to find a way to search through the registry for a key, once found, change it. (also run scandisk) I knew about where it was supposed to be. However keys above it could change at any time. A challenge I was faced with was that I was getting a box appended to the regwrites [] <-- Like that but more box like. This is why I trimmed one character... This works... but I need to learn how to do it better.

Special thanks to Haley who's code I am "using" to get this done.

; written poorly by Jason 
; The Registry search function is from Haley from the autoit forum (thanks man!)
; Searchs for a reg entry changes it and makes chkdsk run

#include <GUIConstants.au3>
#include <Array.au3>
#include <file.au3>

GUICreate("Searching the Registry",500,80)
$info_text = GUICtrlCreateLabel("",10,10,480,60)

Global $found = ""
Global $Jarray
Dim $value
; Search for the userwritecache setting 

; Change what we found
$Jarray = StringSplit ($found, "#")
_ArraySort ($Jarray)

While UBound($Jarray) > 0
   $value = _ArrayPop($Jarray)
    If StringinStr ($value, "HKLM") Then
        $value = StringReplace ($value, "\UserWriteCacheSetting", "")
        $value = StringtrimRight ($value, 1)
        RegWrite ($value, "UserWriteCacheSetting", "REG_DWORD", "0")

; Set the dirty bit
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager", "BootExecute", "REG_MULTI_SZ", "autocheck autochk /r \??\C:" & @LF & "autocheck autochk *")

; Recursive search-function
Func SearchReg($startkey,$searchval)
    Local $startkey,$val,$i,$key,$searchval,$z
    $i = 1
    While 1
        $key = RegEnumKey($startkey,$i)
        If @error <> 0 Then ExitLoop
        GUICtrlSetData($info_text,$startkey & "\" & $key)
        $z = 1
        While 1
            $val = RegEnumVal($startkey & "\" & $key,$z)
            If @error <> 0 Then ExitLoop
            If StringInStr($val,$searchval) Then $found = $found & "#" & $startkey & "\" & $key & "\" & $val & @LF
                    $readval = RegRead($startkey & "\" & $key,$val)
            If $readval <> "" And StringInStr($readval,$searchval) Then $found = $found & "Value, " & $startkey & "\" & $key & ", " & $val & ", " & $readval & @LF
            $z = $z + 1
        SearchReg($startkey & "\" & $key,$searchval)
        $i = $i + 1
    _ArrayInsert ( $Jarray, $z, $found)

Yeah I know I most likely made some of you cringe... But do cut me some slack I am learning here, and I got this far on my own.

Share this post

Link to post
Share on other sites

You mean this character: {ASC 127}? (open SciTe and press ALT+127)

Instead of having to shred strings, you can just search for this ASCII character and remove it. It would be a lot simpler.

This is one way you could call the character in your script:

another way would be to press ALT+127 and put the character in quotes.

I hope this is what you were after,

Nomad :D

Edit: 127 7f Delete (rubout), cross-hatch box :wacko:

Edited by Nomad

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...