Using the -r command line switch to fix start up errors in the IDE

Abstract: If you get an error starting your IDE, using the -r command line switch will probably fix the problem

The -r command line switch to the Delphi and C++ Builder IDE's has been around for a long time. To use it, after -r add a name. Common examples are foo (-rfoo) and test (-rtest).  Here are examples of revised shortcuts to launch Rad Studio XE3, Delphi XE3 and C++ Builder XE3:

"C:\Program Files (x86)\Embarcadero\RAD Studio\7.0\bin\bds.exe" -rfoo
"C:\Program Files (x86)\Embarcadero\RAD Studio\7.0\bin\bds.exe" -pDelphi -rfoo
"C:\Program Files (x86)\Embarcadero\RAD Studio\10.0\bin\bds.exe" -pCBuilder -rfoo

To change your shortcut, right click on the shortcut you use to launch your product (commonly in the start menu), and select Properties. Then select the Shortcut tab and modify the target.

Properties Dialog Box

The name you provide after -r is a registry hive. If that registry hive does not exist, the IDE create a brand new registry hive with all the defaults and uses it. Because this takes you back to all the default settings, it fixes most start up problems with the IDE. Note that because custom controls are not part of the defaults, this technique will result in your IDE not having any custom controls you have installed previously. Custom controls are the most common cause of this error, so you will probably want to add any you have one at a time and test.

Your new registry hive will be stored in the registry at HKCU\Software\Embarcadero\name\version. Your current settings for the IDE are stored at HKCU\Software\Embarcadero\BDS\version. You can compare the two registry hives using regedit to see what is different.

Rad Studio XE2 and later also has a -cleanregistryide command line switch which you might find useful. Whereas using -r switch is not destructive, -cleanregistryide is. It will take you back to all the defaults the same as using -r, however it will delete all your current settings. So, if you have a significant investment in your IDE settings, then you my not want to use -cleanregistryide.

Note that the purpose of -r is it allows you to easily switch your IDE to a different set of properties. This is convenient if you have different projects where you need different IDE settings.

Finally, note that all the command line switch settings for the IDE are documented here: docwiki.embarcadero.com/RADStudio/en/IDE_Command_Line_Switches_and_Options