How to Run Multiple/Concurrent Instances on Windows

In one of the project at work we have been using running in headless mode to do document format conversions in the background, i.e. converting to and from various MS Office formats OpenDocument formats and PDF. One problem of using standalone installation as backend is that you can only run one instance at a time. So while you can have a multi-user front end doing various processing, we used to be able to run document format conversion one at a time.

That sucks.

Here's a trick to run multiple instances concurrently, all from one single installation, on Windows. Assuming the latest 3.x is installed. It's actually pretty simple -- just change the USERPROFILE environment variable! Or HOME on Linux/Solaris.

For example, in Java

ProcessBuilder pb = new ProcessBuilder("c:\\Program Files\\ 3\\program\\soffice.exe",
    "-invisible", "-headless", "-nologo", "-nofirststartwizard");
Map<String, String> env = pb.environment();
if (windoze) {
    env.put("USERPROFILE", "c:\\temp\\12345");
} else {
    env.put("HOME", "/tmp/12345");
Process ooo = pb.start();

Yeah I am putting this here because the search result on Google is pretty junky. And I just realised that I have not blogged for yonks. Busy buys busy.