Docfxit Posted February 9, 2015 Author Share Posted February 9, 2015 Try to checkload the reg file with StringRegExp, and after use _WinAPI_RegOpenKey and _WinAPI_RegDeleteKey() Function from RegistryEx.au3 see also Ciao. Thank you for the post. It appears StringRegExp would be great for identifying the correct registry entry. I looked up the function. I don't understand in the example they give what it's actually doing. In example one they have: $aArray = StringRegExp('<test>a</test> <test>b</test> <test>c</Test>', '(?i)<test>(.*?)</test>', $STR_REGEXPARRAYMATCH, $iOffset) I don't understand the subject string. what this '<test>a</test> <test>b</test> <test>c</Test>' I don't understand the pattern it's trying to match. '(?i)<test>(.*?)</test>' I have no idea how I would apply that to what I am trying to do: If StringLeft($MyArrayVariable[$x], 5) = "[Hkey" Then It would be very nice to only need AutoIt using _WinAPI_RegOpenKey and _WinAPI_RegDeleteKey() Functions So I didn't need SetACL but I am not sure how to identify the exact registry entry without first exporting the entries to a file so I know for sure I'm deleting only the entries I want. It would not be nice to create a script that accidentally found entries that didn't apply to the problem I'm trying to correct. Thanks, Docfxit Link to comment Share on other sites More sharing options...
Docfxit Posted February 9, 2015 Author Share Posted February 9, 2015 In reading through this thread from the beginning, I have yet to see an ounce of troubleshooting come from you, only vague questions of "this is the problem, help please" variety. SadBunny stated you have other invalid options when calling SetACL, instead of asking the above, why don't you try Googling SetACL, and see for yourself? I have been googling SetACL for days now. I have found very little on changing the owner or adding a user to the permissions of a registry key. Most posts deal with files. I have also sent two emails to the person that created SetACL. So far I have had no response. You are suggesting I search for setacl parameters. I have been looking at the parameters for days. It doesn't suggest how to change a registry entry or show an example. The only examples I have been able to find include the space between the "-" and the option. On the page by the author for SetACL parameters it shows: Registry read Read (KEY_ENUMERATE_SUB_KEYS + KEY_EXECUTE + KEY_NOTIFY + KEY_QUERY_VALUE + KEY_READ + READ_CONTROL) full Full access (KEY_CREATE_LINK + KEY_CREATE_SUB_KEY + KEY_ENUMERATE_SUB_KEYS + KEY_EXECUTE + KEY_NOTIFY + KEY_QUERY_VALUE + KEY_READ + KEY_SET_VALUE + KEY_WRITE + READ_CONTROL + WRITE_OWNER + WRITE_DAC + DELETE) I find that hard to interpret how that applies to my situation. There are no examples. I'm very sorry you feel I have spent no time trying to figure this out myself. I feel I have spent a lot of time trying to figure this out on my own. Docfxit Link to comment Share on other sites More sharing options...
DXRW4E Posted February 9, 2015 Share Posted February 9, 2015 (edited) expandcollapse popup;#Include <Array.au3> #Include "RegistryEx.au3" Global Const $sLineCompactFormatPattern = '[\h\f\xb\x0]*(?|"((?>[^"\r\n]|"")*)"?((?>[^\h\f\xb\x0\\";\r\n]+|(?>[\\\h\f\xb\x0]+)(?!(?>[\\\h\f\xb\x0]|""(?!")|;[^\n]*)*(?:[\r\n]|$)))*)|((?2)))(?>(?>[\h\f\xb\x0]|""(?!"))*\\(?>[\\\h\f\xb\x0]|""(?!")|;[^\n]*)*\r?\n)*(?>(?:[\\\h\f\xb\x0]|""(?!")|;[^\n]*|\r?\n)+(?=[\r\n]|$))*' Global Const $sLineCompactFormatPatternEx = '[\h\f\xb\x0]*(?|"((?>[^"\r\n]|"")*)"?((?>[^\h\f\xb\x0\\";\r\n]+|(?>[\\\h\f\xb\x0]+)(?!(?>[\\\h\f\xb\x0]|""(?!")|;[^\n]*)*(?:[\r\n]|$)))*)|((?2)))(?>(?>[\h\f\xb\x0]|""(?!"))*\\(?>[\\\h\f\xb\x0]|""(?!")|;[^\n]*)*\r?\n(?>[\h\f\xb\x0]*;[^\n]*\n)*)*(?>(?:[\\\h\f\xb\x0]|""(?!")|;[^\n]*|\r?\n)+(?=[\r\n]|$))*' Global Const $sKeyValueLinePattern = '\n\h*("(?:[^\r\n\\"]*|\\\\|\\")*"|@)\h*=[\h\f\xb\x0]*((?>[^\\";\r\n]+|"(?>[^"\r\n])*"|\\(?>[\\\h\f\xb\x0]|""(?!")|;[^\n]*)*\n?|[";][^\n]*)*)' Global Const $KEY_SET_VALUE_EX = 0x0002 ;; Required to create, delete, or set a registry value. Local $aRegFiles, $sRegFiles, $aKeyValueData, $sKeyHandle, $sSubKey, $sKeyName, $sValueData, $hKey $sRegFiles = StringRegExpReplace(FileRead(@DesktopDir & "\FileName.reg"), '\r\n?', @LF) ;;, '\r(?!\n)', @CRLF) ;;;;, '(?<!\r)\n', @CRLF) $aRegFiles = StringRegExp(StringRegExpReplace($sRegFiles, "(?s)(\n\h*\[\h*)", @LF & ChrW(12) & "["), "\f\[([^\]\r\n\\]+)([^\]\r\n]*)\]\h*(?:;[^\r\n]*)?\s+([^\f]+)", 3) If Not @Error Then ;_ArrayDisplay($aRegFiles) For $i = 0 To UBound($aRegFiles) - 1 Step 3 $sKeyHandle = $aRegFiles[$i] $sSubKey = $aRegFiles[$i+1] $aKeyValueData = StringRegExp(@LF & $aRegFiles[$i+2] & @LF, $sKeyValueLinePattern, 3) ;_ArrayDisplay($aKeyValueData, $sKeyName) For $y = 0 To UBound($aKeyValueData) - 1 Step 2 $sKeyName = $aKeyValueData[$y] $sValueData = StringReplace(StringRegExpReplace($aKeyValueData[$y+1], $sLineCompactFormatPattern, "$1$2"), '""', '"', 0, 1) ConsoleWrite($sKeyName & " - "& $sValueData & @LF) Next Next For $i = 0 To UBound($aRegFiles) - 1 Step 3 $sKeyHandle = $aRegFiles[$i] $sSubKey = ($aRegFiles[$i+1] ? "\" & $aRegFiles[$i+1] : "") ;_ArrayDisplay($aKeyValueData, $sKeyName) $hKey = _WinAPI_RegOpenKey(Null, $sKeyHandle & $sSubKey, $KEY_SET_VALUE_EX) If Not @Error Then $aKeyValueData = StringRegExp(@LF & $aRegFiles[$i+2] & @LF, $sKeyValueLinePattern, 3) If Not @Error Then For $y = 0 To UBound($aKeyValueData) - 1 Step 2 $sKeyName = StringReplace(StringRegExpReplace($aKeyValueData[$y], $sLineCompactFormatPattern, "$1$2"), '""', '"', 0, 1) $sValueData = StringReplace(StringRegExpReplace($aKeyValueData[$y+1], $sLineCompactFormatPattern, "$1$2"), '""', '"', 0, 1) If $sValueData == "-" Then _WinAPI_RegDeleteValue($hKey, $sKeyName) Next EndIf EndIf _WinAPI_RegCloseKey($hKey) Next EndIfRegistryEx.au3 is much faster and more secure in comparison with the SetACL or any other way, with RegistryEx.au3 no need to check and after taking permission of the Registry key and after Edit Registry etc etc and after restore original permissions in poor words with RegistryEx.au3 do not matter if you have or do not have permission of the registry key, _WinAPI_RegOpenKey (always open a Key) and _WinAPI_RegDeleteValue always delete the Value etc etc etc _WinAPI_Reg*** always edit Registry without changing the original security permissionsCiao. Edited February 15, 2015 by DXRW4E Link to comment Share on other sites More sharing options...
SadBunny Posted February 9, 2015 Share Posted February 9, 2015 Thanks for pointing that out. I wasn't able to see that. I discovered the problem was I had a space between the "-" and the option. The "-" belongs there in front of the option. The samples I found on the internet had the space also. You mentioned "By the way, the way you wrote it now, there's a lot more invalid options. "-" is just the first one it finds." I have corrected the "-" option. It seems to run. What other invalid options are you seeing? Thank you very much, Docfxit I meant that if for instance you give "- actn setowner", you have three incorrect options, "-", "actn" and "setowner". If you remove that space (which you now did) then everything is suddenly ok. This situation happened 3 times in your initial commandline, so that would be 9 invalid options in total Removing the three spaces suddenly leads to three options with one argument each, which looks a lot better. Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
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