批处理文件中的 Windows 7 32 位程序文件路径问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4796577/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 08:00:44  来源:igfitidea点击:

Windows 7 32-bit Program Files path in a Batch file Issue

windowspathbatch-file

提问by KCavon

I have batch file that I am inheriting and I cannot get to work in a 64bit Windows 7 environment. The batch file makes a call to a java script, and passes two variables in it. The old on looked like this:

我有要继承的批处理文件,但无法在 64 位 Windows 7 环境中工作。批处理文件调用 java 脚本,并在其中传递两个变量。旧的看起来像这样:

 C:\Progra~1\salesf~1.com\ApexDa~2.0\bin\process.bat     C:\Progra~1\*PATH*     *VARIABLE*

This was run onm 32bit XP which has just the one program files. I have tried every way I can think of to change the being of the the path to Program fiels x86. I have tried SET PATH, SET ExecPath, %ProgrmaFiles(x86), but they all return cannot find the path specified. I am sure the answer is easy, and I know there is a much beeter way to do this, and it will be changed, but for the moment, I need this to work. Any help, much appreciated.

这是在只有一个程序文件的 32 位 XP 上运行的。我已经尝试了所有我能想到的方法来改变 Program fiels x86 的路径。我尝试了 SET PATH、SET ExecPath、%ProgrmaFiles(x86),但它们都返回找不到指定的路径。我相信答案很简单,而且我知道有一种更好的方法可以做到这一点,并且会有所改变,但目前,我需要这样做。任何帮助,非常感谢。

回答by the_mandrill

If you type

如果你输入

 dir /x c:\

then this shows the directory listing in the 8.3 format. Program Filesexpands to PROGRA~1and Program Files (x86)expands to PROGRA~2. So I think you'll need to change the script to use PROGRA~2

那么这将显示 8.3 格式的目录列表。 Program Files扩展到PROGRA~1Program Files (x86)扩展到PROGRA~2. 所以我认为您需要更改脚本才能使用PROGRA~2

EDIT: I agree with Mark that this isn't ideal -- it depends how much you are able to change of the legacy scripts. On a Win7 machine you should be able to use %ProgramFiles%and %ProgramFiles(x86)%(note the trailing '%').

编辑:我同意 Mark 的观点,这并不理想——这取决于您能够更改旧脚本的程度。在 Win7 机器上,您应该能够使用%ProgramFiles%%ProgramFiles(x86)%(注意尾随的“%”)。

回答by Smitha

export JAVA_HOME=/cygdrive/c/Progra~1/java/jdk1.7.0_40/

导出 JAVA_HOME=/cygdrive/c/Progra~1/java/jdk1.7.0_40/

This worked for me.

这对我有用。