schilbiz Posted November 26, 2008 Share Posted November 26, 2008 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 More sharing options...
Mobius Posted November 26, 2008 Share Posted November 26, 2008 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. Link to comment Share on other sites More sharing options...
schilbiz Posted November 26, 2008 Author Share Posted November 26, 2008 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 More sharing options...
schilbiz Posted November 26, 2008 Author Share Posted November 26, 2008 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 More sharing options...
Mobius Posted November 26, 2008 Share Posted November 26, 2008 (edited) Yes otherwise I would not have posted, Not up to scratch on things are you dude, File extensions MEAN NOTHINGED::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) #ENDREGIONVlad Edited November 28, 2008 by Mobius Link to comment Share on other sites More sharing options...
schilbiz Posted December 1, 2008 Author Share Posted December 1, 2008 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 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