I can easily create a new Firefox Profile in a custom directory using the command:
String profileName = "ABC XYZ";
Runtime rt = Runtime.getRuntime();
String dir = "C:\\My Custom Dir\\profileName";
String executeCommand = "cmd.exe /c start firefox -CreateProfile \"" + profileName.replaceAll("\s", "_") + " " + customFirefoxProfileDir + "\"";
Process process = rt.exec(executeCommand);
The problem I'm encountering is that if I don't replace empty spaces in the profileName with an underscore (or some other character) the Profile will be generated only using the first word in profileName (i.e, ABC instead of ABC XYZ).
After researching this for some time, I believe this queer phenomenon stems from the fact that Firefox does not allow spaces in the Profile Name.
-CreateProfile profile_name
Create a new profile in the default directory, but do not start the application. The profile will be named profile_name in the profile manager, the profile_name must not contain spaces().
While I can always automatically replace empty spaces with underscores, the problem is that there's no way for me to enforce this convention as some of the profiles are being created manually through the Choose User Profile Dialog with spaces.
Oddly, when clicking Create Profile in the Firefox - Choose User Profile dialog I am able to name it whatever I want - including with spaces.
So my question is: Is there a way to create a new Firefox Profile programmatically (in Java) while including spaces in the actual Profile Name?
I tried surrounding the profileName with double quotes but it didn't work.