在批处理文件中设置路径

时间:2021-01-04 21:16:57

I am trying to run a batch file that will install several applications without the need for user intervention. All of these applications are installed using their own batch files. The issue I am having is that I cannot seem to get the file to run from the current directory correctly. I have tried to use the "cd /d %~dp0" and the "%CD%" commands and I get the message that the file path is not found. It looks like when running the batch file it is adding an extra backslash command.

我正在尝试运行一个批处理文件,该文件将安装多个应用程序而无需用户干预。所有这些应用程序都使用自己的批处理文件安装。我遇到的问题是我似乎无法正确地从当前目录运行该文件。我试图使用“cd / d%~dp0”和“%CD%”命令,我得到的信息是找不到文件路径。看起来在运行批处理文件时,它会添加一个额外的反斜杠命令。

The code starts off as follows

代码如下开始

SET DRIVE1=%CD%

SET PATHWAY=%~DP0
SET APPL=1

SET INSTALL=
SET /A MARK=0
SET INSTALL1="APPLICATION NAME"

SET PATH1=%DRIVE%\"APPLICATION LOCATION"

SET CMDFOR1="APPLICATION BATCHFILE NAME"

1 个解决方案

#1


0  

Try changing:

SET PATH1=%DRIVE%\"APPLICATION LOCATION"

to this:

SET PATH1="%DRIVE%\APPLICATION LOCATION"

Note that the quotation is moved to the left of the %DRIVE% variable.

请注意,引用将移动到%DRIVE%变量的左侧。

#1


0  

Try changing:

SET PATH1=%DRIVE%\"APPLICATION LOCATION"

to this:

SET PATH1="%DRIVE%\APPLICATION LOCATION"

Note that the quotation is moved to the left of the %DRIVE% variable.

请注意,引用将移动到%DRIVE%变量的左侧。