gseller Posted October 22, 2008 Share Posted October 22, 2008 (edited) Hi all, I am reading a registry key and writing to an ini, this is to make a change back after another process. I am writing a REG_BINARY using a string from this ini as in the help file. I cannot get this variable $rIni[$i][1] to be written to the reg. it errors out. If I make this a simple string line kk05 it will write it. Can someone offer a king work to help me please? Thank You in advance... edit:forgot a word $sIni = @ScriptDir & "\xxxxxxx.ini" $var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Telephony\XXXXXXX", "Workstation ID") ;MsgBox(4096, "Workstation ID:", $var) ; Demonstrate creating a new section using a string as input. ;$sData = $var ;IniWriteSection($sIni, "Section1", $sData) IniWrite(@ScriptDir & "\xxxxxxx.ini", "section", "key", $var) $rIni = IniReadSection(@ScriptDir & "\xxxxxxx.ini", "section") If @error Then MsgBox(4096, "", "Error occurred, probably no INI file.") Else For $i = 1 To $rIni[0][0] MsgBox(4096, "", $rIni[$i][1]) Next EndIf RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Telephony\XXXXXXX", "Workstation ID", "REG_BINARY", $rIni[$i][1]) Edited October 22, 2008 by gesller Link to comment Share on other sites More sharing options...
dbzfanatic Posted October 22, 2008 Share Posted October 22, 2008 Did you try using String($rIni[$i][1])? That's the only thing I can think of right now. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
gseller Posted October 22, 2008 Author Share Posted October 22, 2008 Thanks, not sure how that would work, but thank you for the reply Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 22, 2008 Share Posted October 22, 2008 (edited) Hi all, I am reading a registry key and writing to an ini, this is to make a change back after another process. I am writing a REG_BINARY using a string from this ini as in the help file. I cannot get this variable $rIni[$i][1] to be written to the reg. it errors out. If I make this a simple string line kk05 it will write it. Can someone offer a king work to help me please? Thank You in advance... edit:forgot a word $sIni = @ScriptDir & "\xxxxxxx.ini" $var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Telephony\XXXXXXX", "Workstation ID") ;MsgBox(4096, "Workstation ID:", $var) ; Demonstrate creating a new section using a string as input. ;$sData = $var ;IniWriteSection($sIni, "Section1", $sData) IniWrite(@ScriptDir & "\xxxxxxx.ini", "section", "key", $var) $rIni = IniReadSection(@ScriptDir & "\xxxxxxx.ini", "section") If @error Then MsgBox(4096, "", "Error occurred, probably no INI file.") Else For $i = 1 To $rIni[0][0] MsgBox(4096, "", $rIni[$i][1]) Next EndIf RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Telephony\XXXXXXX", "Workstation ID", "REG_BINARY", $rIni[$i][1]) Your RegWrite is outside the For/Next loop, so only the last value gets written, but maybe that's intended... Quoting the help file under RegRead(): When reading a REG_BINARY key the result is a binary datatype (in previous versions it was a string of hex characters). When you RegRead() a REG_BINARY type the variable is a binary, which cannot be directly stored in an .ini file. The IniWrite() function probably converts it to a hex char string for you, but IniRead() will certainly give you a string, which you may need to convert back to binary before RegWrite(): $bIni = Binary($rIni[$i][1]) RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Telephony\XXXXXXX", "Workstation ID", "REG_BINARY", $bIni) Edited October 22, 2008 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
gseller Posted October 22, 2008 Author Share Posted October 22, 2008 PsaltyDS, I thought that too.. Thought I was gonna have to do a string split and put in a coma delimiter but thank God, it worked.. I was able to get the variable to regwrite by putting the regwrite back in the for loop. It all works now if it is split up from regread and write to an ini in one function and the regwrite in another. Thanks so much for your help... 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