Docfxit Posted February 8, 2015 Share Posted February 8, 2015 (edited) I have a script that I think I have a few problems with. The first problem is in my For $x loop. It isn't executing the For statement. expandcollapse popup; Delete all registry keys in .reg file ; #RequireAdmin #include <file.au3> #include "ExtMsgBox.au3" Dim $MyArrayVariable, $MsgBoxText, $x $FileToRead = "D:\Dnload\%Test\SuperSpeed.reg" ; Read reg file into array If _FileReadToArray($FileToRead, $MyArrayVariable) Then For $i = 1 To $MyArrayVariable[0] $MsgBoxText = $MsgBoxText & $i & " " & $MyArrayVariable[$i] & @CRLF Next Else ; returncode was 0 so the function reported that the file doesn't exist MsgBox(0, "Error", "File Doesn't exist - " & $FileToRead) EndIf For $x = ($i - 1) To 1 Step -1 If StringLeft($MyArrayVariable[$x], 5) = "[Hkey" Then _DeleteKey($MyArrayVariable[$x]) EndIf Next Exit Func _DeleteKey($RegistryEntry) Local $SetACL_On = "C:\Batch\SetACL.exe -on" Local $SetACL_Owner = ' -ot reg -actn setowner -ownr "n:Administrators"' Local $SetACL_AddPermissions = ' -ot reg -actn ace -ace "n:Administrators;p:full' Local $RegistryEntry1 = StringTrimRight($RegistryEntry, 1) ; Remove the ] rightmost character from the string. Local $RegistryEntry2 = StringTrimLeft($RegistryEntry1, 1) ; Remove the [ leftmost character from the string. Local $RegistryEntry3 = '"' & $RegistryEntry2 & '"' ; Remove the [ leftmost character from the string. _ExtMsgBoxSet(1 + 32 + 64, 1, 0x0DF4E8, 0, 11, "Nyala", @DesktopWidth - 20) $sMsg = @ComSpec & " /c " & $SetACL_On & " " & $RegistryEntry3 & " " & $SetACL_Owner ;AutoIt_Debugger_Command:Enable_Debug $iRetValue = _ExtMsgBox(0, " ", "Please Wait for 10 seconds", $sMsg, 10, 400, 400) RunWait(@ComSpec & ' /k ' & $SetACL_On & " " & $RegistryEntry3 & " " & $SetACL_Owner, "", @SW_MAXIMIZE) RunWait(@ComSpec & " /k " & $SetACL_On & " " & $RegistryEntry3 & " " & $SetACL_AddPermissions, "", @SW_MAXIMIZE) Sleep(3000) ;RegDelete($RegistryEntry3) ;AutoIt_Debugger_Command:Disable_Debug EndFunc ;==>_DeleteKey Thank you, Docfxit Edited February 9, 2015 by Docfxit Link to comment Share on other sites More sharing options...
Spider001 Posted February 8, 2015 Share Posted February 8, 2015 I,am not on pc but i think you need to have Line 34 write "step - 1" after it Link to comment Share on other sites More sharing options...
Docfxit Posted February 8, 2015 Author Share Posted February 8, 2015 (edited) That fixed the For loop. Thank you, Now I'm getting an error on; RunWait(@ComSpec & " /c " & REG DELETE "$RegistryEntry", "", @SW_HIDE) syntax error ~~~~~~~~~~~~~~~~^ Edited February 8, 2015 by Docfxit Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 8, 2015 Moderators Share Posted February 8, 2015 RunWait(@ComSpec & " /c REG DELETE " & $RegistryEntry, "", @SW_HIDE) Although, what's wrong with RegDelete() function? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Docfxit Posted February 8, 2015 Author Share Posted February 8, 2015 (edited) Great suggestion. I'm now having a problem with this line: If $MyArrayVariable[$x] = "[Hkey" Then I would like it to match only on the first 5 characters. The entire line looks like this: [HKEY_LOCAL_MACHINESYSTEMControlSet001EnumSWControl] Thank you, Docfxit Edited February 8, 2015 by Docfxit Link to comment Share on other sites More sharing options...
jguinch Posted February 8, 2015 Share Posted February 8, 2015 ? If StringLeft($MyArrayVariable[$x], 5) = "[Hkey" Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Docfxit Posted February 8, 2015 Author Share Posted February 8, 2015 (edited) If StringLeft($MyArrayVariable[$x], 5) = "[Hkey" That works really great. Thank you. I am now finding out this isn't working. RunWait(@ComSpec & " /c " & $SetACL_On & " " & $RegistryEntry & " " & $SetACL_AddPermissions, "", @SW_HIDE) I did add #RequireAdmin I have added a msgbox to prove the SETACL has the correct text and spacing. I don't know what else to try. Thanks, Docfxit Edited February 8, 2015 by Docfxit Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 8, 2015 Moderators Share Posted February 8, 2015 Seriously? Is anything working from before? Try debugging it, show what you tried, then post. Not right having others go through your entire script fixing issues you haven't debugged or attempted to find solutions for yourself. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Docfxit Posted February 8, 2015 Author Share Posted February 8, 2015 (edited) Hi SmOke_N I did try to find solutions. I am sorry I didn't know how to resolve these issues myself. I certainly wish I did. I knew when I first posted it that I had problems that I didn't know how to fix. Thanks, Docfxit Edited February 8, 2015 by Docfxit Link to comment Share on other sites More sharing options...
Michiel Posted February 9, 2015 Share Posted February 9, 2015 Why not use /K instead of /C and change @SW_HIDE into @SW_MAXIMIZED? Link to comment Share on other sites More sharing options...
Docfxit Posted February 9, 2015 Author Share Posted February 9, 2015 Thank you Michiel, I see the error now. I will try to fix it. Thanks, Docfxit Link to comment Share on other sites More sharing options...
Michiel Posted February 9, 2015 Share Posted February 9, 2015 If you get stuck, post the error and we can continue from there. Link to comment Share on other sites More sharing options...
Docfxit Posted February 9, 2015 Author Share Posted February 9, 2015 (edited) I currently have a mess. I'm sure there must be an easier way to do this. This is what I started: Local $RegistryEntry1 = StringTrimRight($RegistryEntry, 1) ; Remove the ] rightmost character from the string. Local $RegistryEntry2 = StringTrimLeft($RegistryEntry1, 1) ; Remove the [ leftmost character from the string. Local $RegistryEntry3 = """ & $RegistryEntry2 & """ ; Add Quotes to the string. The $RegistryEntry starts with this: [HKEY_LOCAL_MACHINESYSTEMControlSet002EnumSW1&79f5d87&0&0001] I removed the brackets on the left and right. I need to add a quote on either side of the registry key. What $RegistryEntry3 currently has is " $RegistryEntry2 " What is should be is: "HKEY_LOCAL_MACHINESYSTEMControlSet002EnumSW1&79f5d87&0&0001" So I need to figure out how to resolve the variable and remove the spaces before and after the registry entry. Thanks, Docfxit Edited February 9, 2015 by Docfxit Link to comment Share on other sites More sharing options...
Michiel Posted February 9, 2015 Share Posted February 9, 2015 Use: '"' & $var & '"' Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 9, 2015 Moderators Share Posted February 9, 2015 '"' & $sVar & '"' Or you were close: """" & $sVar & """" Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Docfxit Posted February 9, 2015 Author Share Posted February 9, 2015 I'm getting this error when I run it: ERROR in command line: Invalid option specified: -! Type 'SetACL -help' for help. This is what the cmd line looks like: C:Windowssystem32cmd.exe /c C:BatchSetACL.exe -on "HKEY_LOCAL_MACHINESYSTEMControlSet001EnumSWDiskSuperSpeed_RamDisk_9_01&1a590e2c&0&0001LogConf" - ot reg - actn setowner - ownr "n:Administrators" Note: It's all on one line. Thanks, Docfxit Link to comment Share on other sites More sharing options...
SadBunny Posted February 9, 2015 Share Posted February 9, 2015 (edited) Well, not that this has anything to do with AutoIt any more, but ok... The error message is pretty clear! Option "-" is not a valid option, yet you try to use it three times. By the way, the way you wrote it now, there's a lot more invalid options. "-" is just the first one it finds. Edited February 9, 2015 by SadBunny Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
DXRW4E Posted February 9, 2015 Share Posted February 9, 2015 (edited) Try to checkload the reg file with StringRegExp, and after use _WinAPI_RegOpenKey and _WinAPI_RegDeleteKey() Function from RegistryEx.au3 see also Ciao. RegistryEx.au3 Edited February 9, 2015 by DXRW4E Link to comment Share on other sites More sharing options...
Docfxit Posted February 9, 2015 Author Share Posted February 9, 2015 Well, not that this has anything to do with AutoIt any more, but ok... The error message is pretty clear! Option "-" is not a valid option, yet you try to use it three times. By the way, the way you wrote it now, there's a lot more invalid options. "-" is just the first one it finds. 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 Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted February 9, 2015 Moderators Share Posted February 9, 2015 What other invalid options are you seeing? 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? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! 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