Jump to content

Question: Remove "Key" from multiple .reg files.


schilbiz
 Share

Recommended Posts

Hello,

I have an issue that I could use some advice on. I need to remove a Key from multiple .reg files. Is there some possible way to use RegRead, RegDelete, etc in this instance?

This is the office.reg file to be specific and I need to remove a Key and all sub-keys in multiple office.reg files.

In DOS I normally would do something like: Reg Delete \\remotepcname\HKLM\Software\etc /v Key which would delete the key and every value under it.

Again this only works in the active registry of that remote pc, not a .reg that I know of.

So what I think it comes down to reading the .reg file line by line like a .txt file and removing the lines in question. Which could be very difficult because there is not a specific number of sub-keys and they are not uniform.

Anyone have an idea on this?

Link to comment
Share on other sites

Hi schilbiz

.reg files are simply INI files and can be parsed using AutoIts brilliant ini functions.

Check out IniDelete()

Which can be used to erase just one key or an entire section from a .reg/.ini file :)

Hope this helps you Dude.

Hey thanks man, I will look into it.

Link to comment
Share on other sites

So I tried out a couple things and have not been successful yet. I assumed from what you mentioned that I could do something like this.

1st attempt.

IniDelete("C:\1office.reg", '[HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Access]', "")oÝ÷ ÛiÝjÛ^ZºÚ"µÍÌÍÙ[HH[SÜ[ ][ÝÐÎÌLÌ[ÙXÙKYÉ][ÝÈ
B[Q[]J  ÌÍÙ[K    ÌÎNÖÒÑVWÐÕTSÕTÑTÌLÔÛÙØIÌLÓZXÜÜÛÙ    ÌLÓÙXÙIÌLÌLK  ÌLÐXØÙÜ×IÌÎNË  ][ÝÉ][ÝÊB[PÛÜÙJ  ÌÍÙ[J

Have you verified whether or not IniDelete works on .reg files or do I have to rename them to .ini to edit them?

Thanks

Link to comment
Share on other sites

Yes otherwise I would not have posted, Not up to scratch on things are you dude, File extensions MEAN NOTHING

ED::

Aight I went off on one, I hope this is what you are after::

#REGION Declaration
$section = "HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Access"    ; KEY
$type = "*.reg"
#ENDREGION
#REGION Main
$h_F = FileFindFirstFile($type)
IF $h_F <> -1 THEN
 WHILE 1
    $fname = FileFindNextFile($h_F)
    IF @ERROR THEN EXITLOOP
    IniDelete($fname,$section)
 WEND
ELSE
 MsgBox(0,@SCRIPTNAME,"Could not find any files of type "& $type)
ENDIF
FileClose($h_F)
#ENDREGION

Vlad

Edited by Mobius

wtfpl-badge-1.png

Link to comment
Share on other sites

Thanks for the input.

I found out what was stopping me from editing the files. You have to change the attribute on the files in order to edit them. By default .ini's are "read only". So I just needed to change attribute before and after the IniDelete() to remove the "read only" status and set it back to "read only" when finished editing.

$var = "c:\*.reg"

FileSetAttrib($var, "-R")
IniDelete ( "$var", "section" [, "key"] )
FileSetAttrib($var, "+R")
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...