Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: regkey rename
Article ID: W14745
;//*************************************************************************** ;//** Rename registry key ;//** ;//** ****USE AT YOUR OWN RISK***** ;//** This code will export a registry key to a temporary .reg file ;//** Search and replace the registry key name strings in the .reg file ;//** Delete the original registry key ;//** Import modified .REG file containing the renamed items ;//** Delete the temporary .reg file ;//*************************************************************************** temp="c:\temp" RegHandle=@REGCLASSES RegHive="HKEY_CLASSES_ROOT" RegKey="CLSID\{5b4dae26-b807-11d0-9815-00c04fd91972}" Search="CLSID\{5b4dae26-b807-11d0-9815-00c04fd91972}" Replace="CLSID\-{5b4dae26-b807-11d0-9815-00c04fd91972}" TempRegFile="%temp%\~regfile.reg" CaseSensitive=@FALSE ;The /E:A parameter below tells RegEdit to export the file as an ASCII file that ;WinBatch can handle. RunWait("REGEDIT",'/E:A %TempRegFile% %RegHive%\%RegKey%') ;Exports current registry key GoSub SEARCHREPLACE ;Replace Search with Replace, effectively renaming the key reference in the reg file RegDeleteKey(RegHandle,RegKey) ;Delete specified Registry Key RunWait("REGEDIT.EXE",'/s %TempRegFile%') ;Import modified .REG file containing the renamed items FileDelete(TempRegFile) ;Cleanup Exit :SEARCHREPLACE fs = FileSize( TempRegFile ) binbuf = BinaryAlloc( fs*2 ) Sourc = BinaryRead( binbuf, TempRegFile ) num = BinaryReplace( binbuf, Search,Replace ,CaseSensitive) BinaryWrite( binbuf, TempRegFile) BinaryFree(binbuf) Return
Article ID: W13737
Filename: Renaming Registry Keys.txt
File Created: 2014:07:18:09:51:38
Last Updated: 2014:07:18:09:51:38