1

I have the following command:

new ProcessBuilder("cmd.exe", "/c", "C:\\erlang.exe", "/S", "/D=C:\\Program Files\\Erlang OTP")

The Erlang is not installed in the specified directory because the path C:\Program Files\Erlang OTP contains whitespaces. I have tried to escape the whitespaces using \, ^, or to wrap the command in double-quotes but it doesn't seem to work.

If I run the same command directly from cmd it works fine. Do you have any idea if it is possible to specify a path that contains whitespaces using /D option?

Grad Ionut
  • 11
  • 2
  • Have you tried (`\"`) to escape the whitespace ignore? See https://stackoverflow.com/questions/27374195/java-processbuilder-ignores-whitespaces – 2240 Apr 30 '20 at 10:42
  • 1
    @polareper yes I have tried. The problem is that in that command I also have /D= and if I do something like "C:\\Program Files\\Erlang OTP" the /D option does not support double-quotes. This is what I found about /D option: /D sets the default installation directory ($INSTDIR), overriding InstallDir and InstallDirRegKey. It must be the last parameter used in the command line and must not contain any quotes, even if the path contains spaces. Only absolute paths are supported. – Grad Ionut Apr 30 '20 at 10:50
  • Could you work around it by setting an environment variable like this? https://github.com/iesen/rabbitmq-maven-plugin/blob/9646a8ea90e06ed3174025e38757949dfb5be7aa/src/main/java/com/github/iesen/rabbitmq/plugin/manager/WindowsRabbitManager.java#L103 – 2240 May 01 '20 at 07:32
  • That didn't work but I have found a workaround that works: transform the path to a short path so this way it will not contain spaces anymore. Thanks anyway @polareper – Grad Ionut May 03 '20 at 18:44
  • OK, you could probably help some other persons if you posted that workaround as an answer to this question. – 2240 May 03 '20 at 18:46

0 Answers0