WinRar Create SFX Self Extracting Installation Wizard and Add Registry Settings

Saturday, January 19th, 2013

Creating a SFX Installation Wizard with WinRar that Can Modify Registry Settings

WinRar's "SFX options…" dialog does not contain any information or guides that help you modify registry settings after the files for your installation have been extracted.  This is a hinderance, but it is extremely possible to modify registry settings by running a batch file after the installation has been completed.  First, make sure the .bat file is included with the rest of your installation files that you selected before making the SFX archive.  In the "Advanced SFX options" window, click on the Setup tab.  Under "Run after extraction", type in just the name of the .bat file you're going to be running.

The Batch File Itself:

This template batch file checks to see if the operating system is 32-bit or 64-bit.  This is an important distincting as it will affect how you setup keys for each type of operating system.  64-bit system keys are usually placed in the Wow6432Node key, so it is important to make this distinction so that your registry settings will work properly.  This batch file called "Program Registry Adder 1.0" provides examples on how to add and modify registry keys depending on the operating system type.

Download Program Registry Adder 1.0

Adding Keys with a .bat (batch) File:

To add specific keys, you use the following parameters:

REG ADD "HKLM\SOFTWARE\My Proggy\" /f /v "InstallDir" /t REG_SZ /d "%PPROG%

The first parameter specifies which hive and key should be created.  The /f flag forces the addition.  The /v flag is the name of the key that should be created.  The /t flag specifies what type of Registry key should be created.  The example uses REG_SZ, which is just a string.  The possible types are:

Value Type (Use this in the batch File)
Binary REG_BINARY
DWORD REG_DWORD
Expandable String REG_EXPAND_SZ
Multi-String REG_MULTI_SZ
String REG_SZ
Binary REG_RESOURCE_LIST
Binary REG_RESOURCE_REQUIREMENTS_LIST
Binary REG_FULL_RESOURCE_DESCRIPTOR
None REG_NONE
Link REG_LINK
QWORD REG_QWORD

 

Check out more information here.

The /d flag contains the value of the key.

Conclusion

Using both a self extracting installation wizard and a batch file for registry key settings makes for the perfect free to use professional looking installation script. You can always run the batch file silently by removing all pause statements in the script. 

WinRar SFX Custom Start In and Target Paths on Desktop Shortcuts

Saturday, January 19th, 2013

WinRar SFX Custom Start In and Target Paths

When creating a self extracting installation wizard using WinRar, you may want to create a shortcut to your program on the user's desktop.  Typically, these parameters are specified in the "SFX options…" dialog.  In the "Advanced SFX options", click on the "Advanced" tab.  Here, you'll see a section called "Shortcuts".  If you create a shortcut using the "Add shortcut…" button, WinRAR will typically leave out an important undocumented feature.

If you create a desktop shortcut using the "Add shortcut…" button, make sure you set the "Destination folder" to just a slash "\" (no quotes) or the shortcut on the desktop will have the following properties:

Target: "D:\Install Directory\YourProgram.exe"
Start in:

Notice, there is no "Start in:" path.  To fix this, you need to add a "\" to the desktop shortcut parameters manually like so:

D, yourProgramsName.exe, \, "Shortcut Description", "Shortcut name",

Or, make sure you place a "\" (no quotes) for the "Destination folder" in the add shortcut helper.

This problem only affects desktop shortcuts and can be fixed by adding a "\" to the parameters for each desktop shortcut after the program's name.