White spaces in command line arguments. Cannot read "C:\Program Files" properly

Sumod picture Sumod · Feb 13, 2012 · Viewed 7.9k times · Source

I need to run silent installation. The command is like this

setup.exe -silent -response <Response File> -jreLoc <jreLoc>

jreLoc is the folder where bin/java needs to be found.

I have installed JRockit as my JDK and it is installed in "C:\Program Files\Java\jrockit-jre1.6.0_29-R28.2.0"

The problem that I face is the value for jreLoc is read only till "C:\Program" no matter what I do in terms of editing the path or tweaking, double quotes, forward or backward slashes etc.

I use a Python script to set up all the environment and later the Python script calls the setup.exe command.

I have searched online but the workarounds are not working. Any hints or pointers are greatly appreciated.

Answer

Duncan picture Duncan · Feb 13, 2012

All Windows paths containing spaces also have an equivalent path without spaces that you can use if you can't figure out how to get the program to accept the path with spaces.

For your particular example the spaceless path is probably C:\Progra~1\Java\jrockit-jre1.6.0_29-R28.2.0' but if you open a command prompt and usedir /x` on the top level folder that will tell you what it is on your system:

C:\>dir /x c:\progr*
 Volume in drive C is XP System
 Volume Serial Number is D8B8-DBEB

 Directory of c:\

30/01/2012  16:16    <DIR>          PROGRA~1     Program Files
13/02/2012  13:51    <DIR>          PROGRA~2     Program Files (x86)
               0 File(s)              0 bytes
               2 Dir(s)  26,189,307,904 bytes free