jason_erkie Posted July 7, 2006 Posted July 7, 2006 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. expandcollapse popup; 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) GUISetState() Global $found = "" Global $Jarray Dim $value ; Search for the userwritecache setting SearchReg("HKLM\SYSTEM\CurrentControlSet\Enum\IDE","UserWriteCacheSetting") GUIDelete() ; 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") EndIf WEnd ; Set the dirty bit RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager", "BootExecute", "REG_MULTI_SZ", "autocheck autochk /r \??\C:" & @LF & "autocheck autochk *") Exit ;***************************************************** ; 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 WEnd SearchReg($startkey & "\" & $key,$searchval) $i = $i + 1 WEnd _ArrayInsert ( $Jarray, $z, $found) EndFunc 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.
Nomad Posted July 7, 2006 Posted July 7, 2006 (edited) 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: Chr(127)another way would be to press ALT+127 and put the character in quotes. I hope this is what you were after, Nomad Edit: 127 7f Delete (rubout), cross-hatch box Edited July 7, 2006 by Nomad
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now