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

前端 未结 14 1406
星月不相逢
星月不相逢 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:35

    Never hardcode this location. Use the environment variables %ProgramFiles% or %ProgramFiles(x86)%.

    When specifying these, always quote because Microsoft may have put spaces or other special characters in them.

    "%ProgramFiles%\theapp\app.exe"
    "%ProgramFiles(x86)%\theapp\app.exe"
    

    In addition, the directory might be expressed in a language you do not know. http://www.samlogic.net/articles/program-files-folder-different-languages.htm

    >set|findstr /i /r ".*program.*="
    CommonProgramFiles=C:\Program Files\Common Files
    CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
    CommonProgramW6432=C:\Program Files\Common Files
    ProgramData=C:\ProgramData
    ProgramFiles=C:\Program Files
    ProgramFiles(x86)=C:\Program Files (x86)
    ProgramW6432=C:\Program Files
    

    Use these commands to find the values on a machine. DO NOT hardcode them into a program or .bat or .cmd file script. Use the variable.

    set | findstr /R "^Program"
    set | findstr /R "^Common"
    

提交回复
热议问题