Sign in to follow this  
Followers 0
Fzz

Reading registry files

8 posts in this topic

I did a search for this and then realized...there's not much here. Nice new look though.

I'm trying to do a search and replace on some registry files that I've exported.

When I try to open the files with FileReadLine() it give me junk.

Actually is give me this:ÿþW

If I open the .reg file in notepad and then paste it into a new reg file it works fine. It looks like it's a problem with the file I exported with regedit.

Also, when I open it with NotepadEx it says the format is "DOS / Unicode (UTF16-LE)

If I just type it out from dos...it looks ok.

Any ideas?

Thanks

Fz

Share this post


Link to post
Share on other sites



I get this as well... i ended up opening the file in notepad and reading the contents manually.


Sitting comfortably behind the code.

Share this post


Link to post
Share on other sites

the dos command type is able to read unicode files. just do type unicode.txt > normal.txt and you've got a plain text file.

or just save the regfile from regedit in a different format (regedit offers a few in the save as dialog)

Share this post


Link to post
Share on other sites

When you say regsistry files, do you mean in xp/2k or 9x?


Who else would I be?

Share this post


Link to post
Share on other sites

Hi,

You make a seach under particular keys or whole registry ?

I wrote a script ( inspire from http://www.autoitscript.com/forum/index.php?showtopic=1157& from scriptkitty ), wich look under uninstall reg keys ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" ), export it to a file, then scan the file to search a word, read the key, then delete the key within the registry.

Just because each update of my application create a new key.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

You can convert the unicode to normal text by running it through the "type" console command.... The general syntax is: RunWait("cmd /c type oldFile.reg > newFile.reg")

$original = "C:\Documents and Settings\Administrator\Desktop\RegistryFile.reg"
$new = "C:\Documents and Settings\Administrator\Desktop\new.reg"
RunWait('cmd /c type "' & $original & '" > "' & $new & '"')

$file = FileOpen($new, 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

; Read in lines of text until the EOF is reached
While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
    MsgBox(0, "Line read:", $line)
Wend

FileClose($file)
Edited by CyberSlug

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

Nice tip.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I had this issue a while back and Jpm helped me figure it out. It seems exporting it in 9x format makes it readable.

Read Me

Edited by psichosis

We have enough youth. How about a fountain of SMART?

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0