[Windows Mobile Software Development] selyb:
Purpose:

This purpose of this VBScript is to process and organize data in RGU/REG files to remove duplicates, identify faulty entries, and move entries to ascending alphabetical order (the same way it is displayed in a registry editor).

Requirements:

Windows Scripting Host (included in most versions of windows)

rgucomp.exe and cereg400.dll located somewhere in your path (same folder as the script probably won't work if the script is run from another folder)

.reg and .rgu files are expected to be UTF-16LE with BOM

Usage:

Drag a .rgu, .reg, or .hv onto RGUber.vbs OR run "wscript.exe RGUber.vbs example.rgu"

Details:

When an rgu|reg file is specified, RGUber will:

1) create backup of input file

2) rename input file to boot.rgu

3) use rgucomp to convert it to *.hv

4) use rgucomp to convert new .hv to original rgu path\name

5) Reorder all keys in ascending alphabetical order and all values for each key in ascending alphabetical order with default value first

When an hv file is specified, RGUber will:

1) use rgucomp to convert it to *.rgu

2) Reorder all keys in ascending alphabetical order and all values for each key in ascending alphabetical order with default value first

Options

Open RGUber.vbs in your favorite text editor. All options are set at the beginning with (hopefully) meaningful descriptions.

'//Path to rgucomp (leave this as default if rgucomp.exe is located in your system path)
Const RGUCOMP = "rgucomp.exe"

'//Path to notepad, only needed if %OPENAFTER% is true
Const NOTEPAD = "notepad.exe"

'//The following options can be set to True/False or 0/1

'//Organize registry entries in ascending alphabetical order
Const REORDER = True

'//Open in %NOTEPAD% after conversion is done
Const OPENAFTER = False

'//Save any errors from rgu -> hv conversion
Const LOGERRORS = True

'//Save a backup copy of %INPUTRGU% as "%INPUTRGU%_Backup.rgu"
Const BACKUPRGU = True

Other info

If target file already exists, RGUber will ask if you want to overwrite.

Text files (the MS way) typically contain CRLF for next line. Output from rgucomp.exe contains many CRCRLF. RGUber removes the extra CR.

I have very few comments in the code. If requested, I will upload another copy with as many detailed comments as I can manage.

I tried to code this as efficiently as VBScript can possibly be. I kept getting errors when trying to run 'rgucomp.exe -b -nologo' so instead of running it directly, RGUber creates a bat file, executes it, then deletes it.

On my AMD Phenom 9600 with Vista64 and 3 SATA in Raid5, RGUber completes rgu->hv->rgu of 2084 lines in <3s

RGUber always saves output from rgu->hv conversion but deletes the file if there were no errors.

RGUber crashes on files with no reg entries (e.g. empty app.reg in an EXT package that does not add any registry entries)

Changelog:

v1.21a

Values are now sorted in alphabetical order for each key

v1.2

Replaced Organize function with one from RGUOrder

Lost ability to reorder values for each key (To be readded in next version)

v1.1

Fixed a bug with removing hashdata from output (RGUber would mix data from two keys under one)

Changed sorting algorith with a much faster one

v1.02

Added option to remove RegistryUpdate key from rgucomp output

Fixed a typo where RGUber was not removing the system attribute from input rgu files

v1.01

Fixed typo where RGUber was waiting for backup file instead of log file

Change 'Done' msgbox to one that shows beginning time and ending time

v1.0

Initial Release

RGUOrder v1.4

This script will only reorder the contents of an rgu without processing with RGUComp, thereby keeping comments and delete key entries. RGUComp/cereg400.dll are not needed to use this app.

Changelog:

v1.4

Fixed a bug where if the original rgu did not end with a new line then the last entry after being sorted would be lost.

Fixed two bugs where only the first 25 tabs and first 25 spaces would be removed before sorting (This did not affect data integrity or performance, but the checksum would be different each time you run the output back through RGUOrder until all the original tabs/spaces were removed)

Added code to prevent multiple entries of the same key from being reordered

Fixed other miscellaneous bugs/oddities introduced with v1.3

v1.3

Added code to add a delete key for each subkey of a deleted key so that when reordered, the key deletion isn't broken

v1.2

Fixed a bug where the last key processed was being concatenated to another with no CRLF producing an invalid rgu file