Sign in to follow this  
Followers 0
sulfurious

FileOpen & FileReadLine on .reg file errors

8 posts in this topic

Export a regkey with any version of windows.

Fileopen it.

while 1

(readline)

if @error = -1 = this creates an endless loop, never stops

msgbox (line) = looks like binary, only reads one line

Wend

Seems even if I FileCopy it as .txt, same issue. Is there some sort of encoding that happens when it is exported as a .reg file? Is it possible to read a .reg file as text?

Help!

Thanks,

Sul

Share this post


Link to post
Share on other sites



A .reg file is just a plain text file. It works the same way as a .txt file as far as I know. Can we see your FileReadLines?

Share this post


Link to post
Share on other sites

Export a regkey with any version of windows.

Fileopen it.

while 1

(readline)

if @error = -1 = this creates an endless loop, never stops

msgbox (line) = looks like binary, only reads one line

Wend

Seems even if I FileCopy it as .txt, same issue. Is there some sort of encoding that happens when it is exported as a .reg file? Is it possible to read a .reg file as text?

Help!

Thanks,

Sul

The registry data is output as unicode.

Search this forum for lots of discussion on converting to ASCII, if desired... :P


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

Share this post


Link to post
Share on other sites

#include <file.au3> 

Global $filein,$line
$filein = FileOpen(@DesktopDir & "aaa.reg",0)
while 1
    $line = FileReadLine($filein)
    if @error = -1 then ExitLoop
    MsgBox(0,"",$line)
WEnd

Share this post


Link to post
Share on other sites

I knew it was unicode. I saved the .reg file as all allowable filetypes. That did not work. Then I exported the registry as type xp,9x,and txt. That did not work. I will look into the conversion. Thanks.

Sul

Share this post


Link to post
Share on other sites

LOL. That was stupid on my part. I used this

Run(@Comspec & ' /c FIND /V "some string never found" c:\file.reg >c:\newfile.reg)

while you were posting on searching for conversions. I had looked up .reg and registry & converions, but did not add the ASCII. I found what you were talking about right away. I should have known to be using Type. I just forgot about it and used Find instead. Type is better because it does not add the --------Found information at the top.

Thanks for the help.

Sul

Share this post


Link to post
Share on other sites

#include <file.au3> 

Global $filein,$line
$filein = FileOpen(@DesktopDir & "aaa.reg",0)
while 1
    $line = FileReadLine($filein)
    if @error = -1 then ExitLoop
    MsgBox(0,"",$line)
WEnd
You are missing the backslash in your "path\to\the\regfile" :P and this will cause failure.

Share this post


Link to post
Share on other sites

How correct you are. The actual script I am working on had other variables to make the path. That was an example. I corrected it and still came up with ÿþS as the first line. The Type method works for now.

Sul

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