iamtheky Posted February 17, 2012 Posted February 17, 2012 (edited) the script i am working on scours an au3 for regwrites - and makes an au3 filled with regread statements for those keys. A simpler version worked fine, but as I try to make it a little This is 'colored' in scite correctly with my intent, with $log being a string in this script but a variable in the next, and the array items being variables in this script resulting in strings in the next. Still playing with quote configuration but no luck yet. Thanks for any assistance. $RegArray[$i] = 'If Regread(" '& $stringArray[0] & "," & $stringArray[1] & ") <> "" Then'" & @CRLF & _ 'filewrite($log & "," ' & $stringArray[0] & "," & $stringArray[1] & '=' & Regread($stringArray[0] & "," & $stringArray[1])'' & @CRLF & _ 'Else' & @CRLF & _ 'filewrite($log & "," ' & $stringArray[0] & "," & $stringArray[1] & '= "Empty or Does Not Exist")' & @CRLF & _ "Endif" & @CRLF & _ @CRLF Edited February 17, 2012 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
water Posted February 17, 2012 Posted February 17, 2012 The file you write should contain something like this? $key = "keyname" $value = "valuename" $RegData = Regread($key, $value) If $RegKey <> "" Then filewrite($log, $key & "," & $value & " = " & $RegData) Else filewrite($log, $key & "," & $value & " = Empty or Does Not Exist") Endif My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted February 17, 2012 Posted February 17, 2012 if yes, then the script should look like; Global $stringArray[2] = ["keyname", "valuename"] Global $RegArray[1] $RegArray[0] = '$key = "' & $stringArray[0] & '"' & @CRLF & _ '$value = "' & $stringArray[1] & '"' & @CRLF & _ '$RegData = Regread($key, $value)' & @CRLF & _ 'If $RegKey <> "" Then' & @CRLF & _ ' filewrite($log, $key & ", " & $value & " = " & $RegData)' & @CRLF & _ 'Else' & @CRLF & _ ' filewrite($log, $key & ", " & $value & " = Empty or Does Not Exist")' & @CRLF & _ 'Endif' & @CRLF ConsoleWrite($RegArray[0] & @CRLF) My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
iamtheky Posted February 17, 2012 Author Posted February 17, 2012 (edited) thanks water, this seems to result in the desired output. There are still issues with the resulting file in that some of the RegRead lines blow up, I tried quoting the Keys in case it was an issue with spaces, but that does not seem to be the case. *replaced below Edited February 17, 2012 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
water Posted February 17, 2012 Posted February 17, 2012 The example you now posted doesn't look like you implemented my code Can you implement my code and try again? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
iamtheky Posted February 17, 2012 Author Posted February 17, 2012 (edited) I did, but then then some regreads blew up. Then ctrl-z'ed two too many times. ultimately I had to remove a set of quotes and change $RegKey to $Regdata, but yours was ridiculously closer than mine. Thanks. expandcollapse popup#Include <Array.au3> #Include <File.au3> $string = FileRead ("SomeUpdates.au3") $RegArray = stringregexp ($string , "RegWrite(.*)" , 3) for $i = 0 to ubound($RegArray) - 1 $trim = stringtrimleft($RegArray[$i] , 1) $trim = stringtrimright($trim , 1) $stringArray = stringsplit ($trim , "," , 2) $RegArray[$i] = '$key = ' & $stringArray[0] & '' & @CRLF & _ '$value = ' & $stringArray[1] & '' & @CRLF & _ '$RegData = Regread($key, $value)' & @CRLF & _ 'If $RegData <> "" Then' & @CRLF & _ ' filewrite($log, $key & ", " & $value & " = " & $RegData)' & @CRLF & _ 'Else' & @CRLF & _ ' filewrite($log, $key & ", " & $value & " = Empty or Does Not Exist")' & @CRLF & _ 'Endif' & @CRLF next $writefile = FileOpen("test_output.au3" , 2) filewrite($writefile , '$log = fileopen("log.txt" , 2)' & @CRLF) _FileWriteFromArray ($writefile , $RegArray) filewrite($writefile , 'fileclose($log)') FileClose($writefile) Edited February 17, 2012 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
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