A configuration file needs position of another file,
配置文件需要另一个文件的位置,
but that file is located in "C:\Program Files",
但该文件位于“C:\ Program Files”中,
and the path with space in it is not recognized,
并且无法识别其中包含空格的路径,
Is there another way to specify the location without space in it?
还有另一种方法来指定没有空间的位置吗?
14 个解决方案
#1
you should be able to use
你应该可以使用
- "c:\Program Files" (note the quotes)
- c:\PROGRA~1 (the short name notation)
“c:\ Program Files”(注意引号)
c:\ PROGRA~1(短名称表示法)
Try c:\> dir /x (in dos shell)
试试c:\> dir / x(在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.
这将显示为非8dot3文件名生成的短名称。格式是/ N的格式,在长名称之前插入了短名称。如果没有短名称,则会在其位置显示空白。
#2
Never hardcode this location. Use the environment variables %ProgramFiles%
or %ProgramFiles(x86)%
.
切勿对此位置进行硬编码。使用环境变量%ProgramFiles%或%ProgramFiles(x86)%。
When specifying these, always quote because Microsoft may have put spaces or other special characters in them.
指定这些时,请始终引用,因为Microsoft可能在其中放置了空格或其他特殊字符。
"%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
此外,目录可能以您不知道的语言表达。 http://www.samlogic.net/articles/program-files-folder-different-languages.htm
#3
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.
我认为那些建议使用C:\ PROGRA~1名称收到downvotes的原因是因为这些名称被视为Windows最遗忘的遗留功能,也可能是不稳定的,至少在不同的安装之间,尽管可能不在同一台机器。
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.
另外,正如有人在对另一个答案的评论中指出的那样,可以将Windows配置为根本不在文件系统中具有8.3遗留名称。
#4
The Windows shell (assuming you're using CMD.exe) uses %ProgramFiles% to point to the Program Files folder, no matter where it is. Since the default Windows file opener accounts for environment variables like this, if the program was well-written, it should support this.
Windows shell(假设您正在使用CMD.exe)使用%ProgramFiles%指向Program Files文件夹,无论它在何处。由于默认的Windows文件打开器会考虑这样的环境变量,如果程序写得很好,它应该支持这个。
Also, it could be worth using relative addresses. If the program you're using is installed correctly, it should already be in the Program Files folder, so you could just refer to the configuration file as .\config_file.txt if its in the same directory as the program, or ..\other_program\config_file.txt if its in a directory different than the other program. This would apply not only on Windows but on almost every modern operating system, and will work properly if you have the "Start In" box properly set, or you run it directly from its folder.
此外,值得使用相对地址。如果您正在使用的程序安装正确,它应该已经在Program Files文件夹中,因此您可以将配置文件称为。\ config_file.txt,如果它与程序在同一目录中,或者.. \ other_program \ config_file.txt如果它在一个不同于其他程序的目录中。这不仅适用于Windows,而且适用于几乎所有现代操作系统,并且如果您正确设置了“开始”框,或者直接从其文件夹运行它,它将正常工作。
#5
There should be a way to use the full c:\program files
path directly. Often, it involves encapulating the string in quotes. For instance, on the windows command line;
应该有一种方法可以直接使用完整的c:\ program files路径。通常,它涉及将字符串包装在引号中。例如,在windows命令行上;
c:\program files\Internet Explorer\iexplore.exe
will not start Internet Explorer, but
不会启动Internet Explorer,但是
"c:\program files\Internet Explorer\iexplore.exe"
will.
#6
Use the following notations:
使用以下表示法:
- For "C:\Program Files", use "C:\PROGRA~1"
- For "C:\Program Files (x86)", use "C:\PROGRA~2"
对于“C:\ Program Files”,请使用“C:\ PROGRA~1”
对于“C:\ Program Files(x86)”,请使用“C:\ PROGRA~2”
Thanks @lit for your ideal answer in below comment:
感谢@lit在下面的评论中给出了理想的答案:
Use the environment variables %ProgramFiles% and %ProgramFiles(x86)%
使用环境变量%ProgramFiles%和%ProgramFiles(x86)%
:
#7
No.
Sometimes you can quote the filename.
有时您可以引用文件名。
"C:\Program Files\Something"
Some programs will tolerate the quotes. Since you didn't provide any specific program, it's impossible to tell if quotes will work for you.
有些程序会容忍引号。由于您没有提供任何特定程序,因此无法确定引用是否适合您。
#8
Try surrounding the path in quotes. i.e "C:\Program Files\Appname\config.file"
尝试用引号括起路径。即“C:\ Program Files \ Appname \ config.file”
#9
You could try to use:
您可以尝试使用:
C:\PROGRA~1
#10
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
dir c:\ / ad / x
This will provide a listing of only directories and also provide their "Short names".
这将提供仅列出目录的列表,并提供其“短名称”。
#11
You can use the following methods to specify C:\Program Files without a space in it for programs that can't handle spaces in file paths:
对于无法处理文件路径中空格的程序,可以使用以下方法指定C:\ Program Files,但不包含空格:
'Path to Continuum Reports Subdirectory - Note use DOS equivalent (no spaces)
RepPath = "c:\progra~1\continuum_reports\" or
RepPath = C:\Program Files\Continuum_Reports 'si es para 64 bits.
' Path to Continuum Reports Subdirectory - Note use DOS equivalent (no spaces)
RepPath = "c:\progra~2\continuum_reports\" 'or
RepPath = C:\Program Files (x86)\Continuum_Reports 'si es para 32 bits.
#12
Either use the generated short name (C:\Progra~1) or surround the path with quotation marks.
使用生成的短名称(C:\ Progra~1)或用引号括起路径。
#13
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"
以管理员身份运行cmd
用户此命令: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)
然后,在无法处理空间的应用程序中开始使用“C:\ LinkToProgramFiles”。 (此链接可在Windows资源管理器中显示为带有快捷方式符号的文件夹)
Be very careful not to create circular links if you start playing too much with this.
如果你开始玩这个太多,要非常小心不要创建循环链接。
#14
You can just create a folder ProgramFiles at local D or local C to install those apps that can be install to a folder name which has a SPACES / Characters on it.
您可以在本地D或本地C创建一个文件夹ProgramFiles,以安装那些可以安装到其上有SPACES / Characters的文件夹名称的应用程序。
#1
you should be able to use
你应该可以使用
- "c:\Program Files" (note the quotes)
- c:\PROGRA~1 (the short name notation)
“c:\ Program Files”(注意引号)
c:\ PROGRA~1(短名称表示法)
Try c:\> dir /x (in dos shell)
试试c:\> dir / x(在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.
这将显示为非8dot3文件名生成的短名称。格式是/ N的格式,在长名称之前插入了短名称。如果没有短名称,则会在其位置显示空白。
#2
Never hardcode this location. Use the environment variables %ProgramFiles%
or %ProgramFiles(x86)%
.
切勿对此位置进行硬编码。使用环境变量%ProgramFiles%或%ProgramFiles(x86)%。
When specifying these, always quote because Microsoft may have put spaces or other special characters in them.
指定这些时,请始终引用,因为Microsoft可能在其中放置了空格或其他特殊字符。
"%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
此外,目录可能以您不知道的语言表达。 http://www.samlogic.net/articles/program-files-folder-different-languages.htm
#3
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.
我认为那些建议使用C:\ PROGRA~1名称收到downvotes的原因是因为这些名称被视为Windows最遗忘的遗留功能,也可能是不稳定的,至少在不同的安装之间,尽管可能不在同一台机器。
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.
另外,正如有人在对另一个答案的评论中指出的那样,可以将Windows配置为根本不在文件系统中具有8.3遗留名称。
#4
The Windows shell (assuming you're using CMD.exe) uses %ProgramFiles% to point to the Program Files folder, no matter where it is. Since the default Windows file opener accounts for environment variables like this, if the program was well-written, it should support this.
Windows shell(假设您正在使用CMD.exe)使用%ProgramFiles%指向Program Files文件夹,无论它在何处。由于默认的Windows文件打开器会考虑这样的环境变量,如果程序写得很好,它应该支持这个。
Also, it could be worth using relative addresses. If the program you're using is installed correctly, it should already be in the Program Files folder, so you could just refer to the configuration file as .\config_file.txt if its in the same directory as the program, or ..\other_program\config_file.txt if its in a directory different than the other program. This would apply not only on Windows but on almost every modern operating system, and will work properly if you have the "Start In" box properly set, or you run it directly from its folder.
此外,值得使用相对地址。如果您正在使用的程序安装正确,它应该已经在Program Files文件夹中,因此您可以将配置文件称为。\ config_file.txt,如果它与程序在同一目录中,或者.. \ other_program \ config_file.txt如果它在一个不同于其他程序的目录中。这不仅适用于Windows,而且适用于几乎所有现代操作系统,并且如果您正确设置了“开始”框,或者直接从其文件夹运行它,它将正常工作。
#5
There should be a way to use the full c:\program files
path directly. Often, it involves encapulating the string in quotes. For instance, on the windows command line;
应该有一种方法可以直接使用完整的c:\ program files路径。通常,它涉及将字符串包装在引号中。例如,在windows命令行上;
c:\program files\Internet Explorer\iexplore.exe
will not start Internet Explorer, but
不会启动Internet Explorer,但是
"c:\program files\Internet Explorer\iexplore.exe"
will.
#6
Use the following notations:
使用以下表示法:
- For "C:\Program Files", use "C:\PROGRA~1"
- For "C:\Program Files (x86)", use "C:\PROGRA~2"
对于“C:\ Program Files”,请使用“C:\ PROGRA~1”
对于“C:\ Program Files(x86)”,请使用“C:\ PROGRA~2”
Thanks @lit for your ideal answer in below comment:
感谢@lit在下面的评论中给出了理想的答案:
Use the environment variables %ProgramFiles% and %ProgramFiles(x86)%
使用环境变量%ProgramFiles%和%ProgramFiles(x86)%
:
#7
No.
Sometimes you can quote the filename.
有时您可以引用文件名。
"C:\Program Files\Something"
Some programs will tolerate the quotes. Since you didn't provide any specific program, it's impossible to tell if quotes will work for you.
有些程序会容忍引号。由于您没有提供任何特定程序,因此无法确定引用是否适合您。
#8
Try surrounding the path in quotes. i.e "C:\Program Files\Appname\config.file"
尝试用引号括起路径。即“C:\ Program Files \ Appname \ config.file”
#9
You could try to use:
您可以尝试使用:
C:\PROGRA~1
#10
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
dir c:\ / ad / x
This will provide a listing of only directories and also provide their "Short names".
这将提供仅列出目录的列表,并提供其“短名称”。
#11
You can use the following methods to specify C:\Program Files without a space in it for programs that can't handle spaces in file paths:
对于无法处理文件路径中空格的程序,可以使用以下方法指定C:\ Program Files,但不包含空格:
'Path to Continuum Reports Subdirectory - Note use DOS equivalent (no spaces)
RepPath = "c:\progra~1\continuum_reports\" or
RepPath = C:\Program Files\Continuum_Reports 'si es para 64 bits.
' Path to Continuum Reports Subdirectory - Note use DOS equivalent (no spaces)
RepPath = "c:\progra~2\continuum_reports\" 'or
RepPath = C:\Program Files (x86)\Continuum_Reports 'si es para 32 bits.
#12
Either use the generated short name (C:\Progra~1) or surround the path with quotation marks.
使用生成的短名称(C:\ Progra~1)或用引号括起路径。
#13
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"
以管理员身份运行cmd
用户此命令: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)
然后,在无法处理空间的应用程序中开始使用“C:\ LinkToProgramFiles”。 (此链接可在Windows资源管理器中显示为带有快捷方式符号的文件夹)
Be very careful not to create circular links if you start playing too much with this.
如果你开始玩这个太多,要非常小心不要创建循环链接。
#14
You can just create a folder ProgramFiles at local D or local C to install those apps that can be install to a folder name which has a SPACES / Characters on it.
您可以在本地D或本地C创建一个文件夹ProgramFiles,以安装那些可以安装到其上有SPACES / Characters的文件夹名称的应用程序。