|
|
|||||||
I want to make a script that copy's a complete section to another INI file. Sample file: Code:
the target file does contain the same section. The script must overide that whole secion. I have search the whole forum but couldn't find anything... I tried readprofilestring but i cant copy a whole section. Who can help me |
||||||||
|
|
|||||||
Code: $sSourceINI=".\x.ini" |
||||||||
|
|
|||||||
Thank you.. it works!! |
||||||||
|
|
|||||||
sure it does |
||||||||
|
|
|||||||
The story continous... The INI file is exported by Kixstart from the registry. If I export you see the following: If I open the file in write.exe I see the same INI in a right formatted way. If I export two files from the registry and I want to copy a section to another section and write it back to the registry.. How do I that. Whit the script above i can not copy from/to an unformatted INI file. The one who can give me a solution wil get a Gmail account in return.. |
||||||||
|
|
|||||||
Show us HOW you export the registry thing by KiXtart and we may modify it to export proper format |
||||||||
|
|
|||||||
eh... it seems to me the ini-file is just fine. what is that kladblock-proggie you are using? looks like notepad... anyways, that "ini-file is exported by kixtart from registry"... could you show that code? kixtart does not do it autom. so you have some sorta script there, right? |
||||||||
|
|
|||||||
Kladblok is notepad. I foresee an Issue with chr(13)+chr(10), chr(10)+chr(13), chr(13), chr(10) ... any of these combinations.. |
||||||||
|
|
|||||||
Quote: $Rows = ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Telesnap\SwAdmin\User-List\302\Config-Group", "SnapwareIni") IF Open( 3 , "c:\export.TXT" , 5 ) = 0 If @ERROR = 0 $Rows = WriteLine( 3 , "$Rows + Chr(13) + Chr(10) ) Endif |
||||||||
|
|
|||||||
hmm... so, you say that you only read 1 registry value which has the whole ini-structure in it? |
||||||||
|
|
|||||||
Yes. And I have to copy a section from that INI file to another INI file in the registry |
||||||||
|
|
|||||||
so, you should try this: Code:
you need at least kix version 4.10 for this to worky... |
||||||||
|
|
|||||||
Oke this works... The only thing i need to do is write the INI file back to the registry. I tried this one but it isn't working $array=ReadFile('.\export.txt') Function ReadFile($file) Dim $lf, $f, $_, $t $lf=chr(10) $f=freefilehandle $_=open($f,$file) if @error exit @error endif do $t=$t+$lf+readline($f) until @error $_=close($f) $ReadFile=split(substr($t,2),$lf) EndFunction Function regwrite($subkey,$value,$data,optional $type) DIM $keyarray,$keypath,$loop,$rc if readvalue($subkey, $entry) <> $expression if not $type $type=readtype($subkey, $entry) if @error $type="REG_SZ" endif endif $keyarray=split("$key","\") for $loop=0 to ubound($keyarray) $keypath=$keypath+$keyarray[$loop]+"\" if not KEYEXIST("$keypath") $rc=addkey("$keypath") endif next if KEYEXIST("$key") $rc=writevalue("$subkey","$value","$data",$type) else exit @error endif endif ENDFUNCTION Regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\Telesnap\SwAdmin\User-List\342\Config-Group","SnapwareIni",$array) |
||||||||
|
|
|||||||
Question: Why using writeline() to write to an ini file ? Is there anything speaking against using writeprofilestring(), which of course generates valid format ? Furthermore, is this registry key exported and imported during the same kixtart script run ? |
||||||||
|
|
|||||||
his ini-write is because he has some weird registry value including THE WHOLE ini-file. thus there is no reasoning writing each ini-value separately when you can do it all in one writeline. then, removing all the not-needed sections, writeprofilestring() should be used to trash the not-wanted sections. after that, readfile() udf can be used to read the whole file back with the correct chr(10) separated format. |
||||||||
|
|
|||||||
k, checked the code and can easily say, you have no use for that regwrite() udf. now, I want to once more ask, as this type of stuff I have never seen... is it really so that you have A SINGLE registry value that holds the whole data? all the ini-values and stuff? and that you want to write the stuff back to A SINGLE value? if yes, then nothing. this way it actually is really easy. but if not, please tell as the big picture is something we need to see. |
||||||||
|
|
|||||||
We use a phone program for our CTI/PABX called Snapware. This program stores user configurations to the registry in one key. I have to edit that registry once a week when preforming a update. So i want it scripted.. But i have not figured out how. I can produce the right INI file now but I have to write it back... |
||||||||
|
|
|||||||
why you need the ini? can't you just update the registry-values directly? |
||||||||
|
|
|||||||
Quote: He could, however this started way back as a "how do I copy one ini file section to another". In this case it is probably easier to perserve the intermediate temporary INI files for managing the data, rather than write a special handler for "ini files in registry values" |
||||||||
|
|
|||||||
hmm... I think it could be easiest to finally find out the whole picture. even though, without it he can get it working as he wants. |