How do I specify C:\Program Files without a space in it for programs that can't handle spaces in file paths?

前端 未结 14 1324
星月不相逢
星月不相逢 2020-12-01 04:39

A configuration file needs position of another file,

but that file is located in \"C:\\Program Files\",

and the path with space in it is not recognized,

相关标签:
14条回答
  • 2020-12-01 05:19

    You could try to use:

    C:\PROGRA~1
    
    0 讨论(0)
  • 2020-12-01 05:19

    I think that the other posts have answered the question, but just some interesting for your information (from the command prompt):

    dir c:\ /ad /x

    This will provide a listing of only directories and also provide their "Short names".

    0 讨论(0)
  • 2020-12-01 05:24

    you should be able to use

    • "c:\Program Files" (note the quotes)
    • c:\PROGRA~1 (the short name notation)

    Try c:\> dir /x (in dos shell)

    This displays the short names generated for non-8dot3 file names. The format is that of /N with the short name inserted before the long name. If no short name is present, blanks are displayed in its place.

    0 讨论(0)
  • 2020-12-01 05:25

    I think the reason those suggesting using the C:\PROGRA~1 name have received downvotes is because those names are seen as a legacy feature of Windows best forgotten, which may also be unstable, at least between different installations, although probably not on the same machine.

    Also, as someone pointed out in a comment to another answer, Windows can be configured not to have the 8.3 legacy names in the filesystem at all.

    0 讨论(0)
  • 2020-12-01 05:25

    As an alternative to the other answers, you can try symbolic links.

    Create the symbolic link first and install the application based on the link. (Depending on the case, this may be way easier to do, for instance when the application has n mentions of the target folder throughout its code)

    A symbolic link will create something similar to a shortcut to a folder, but seen as an actual folder by other applications.

    This is how you do it:

    • Run cmd as administrator
    • User this command: mklink /D "C:\LinkToProgramFiles" "C:\Program Files"

    And then, you start using "C:\LinkToProgramFiles" in the applications that can't handle spaces. (This link can be seen in Windows Explorer as a folder with the symbol of a shortcut)


    Be very careful not to create circular links if you start playing too much with this.

    0 讨论(0)
  • 2020-12-01 05:27

    Try surrounding the path in quotes. i.e "C:\Program Files\Appname\config.file"

    0 讨论(0)
提交回复
热议问题