【发布时间】:2016-05-27 11:03:00
【问题描述】:
我有一个运行 ajaxMinfier 并压缩我的 css 和 jquery 的批处理文件。 我的 xml 文件使用相对路径。现在一切都在 Windows 7 中运行,但最近我升级到 Windows 10,现在我的批处理文件失败了。 如果我双击批处理文件会发生什么情况,它无法在同一文件夹中找到我的 xml 文件。
我有这样的
compress.bat
css.xml
jquery.xml
我总是在批处理文件中给出 ajaxMinifier 的完整路径,这很好。它正在运行,但在我的 xml 中给出我的文件的相对路径。原因是我在不同阶段有多个网页副本。
如果我使用命令行进入并运行我的批处理文件,一切正常,但当然我在运行批处理文件的文件夹中。如果我在 Windows 中单击我的批处理文件,它甚至找不到与我的批处理文件位于同一位置的我的 xml 文件。
我在最后暂停了一下,我怀疑原因是它在 C: 中寻找我的 xml 文件,而不是批处理文件的位置。
这是我的批处理文件
::Work
E:\Utilities\AjaxMinifier\AjaxMinifier.exe -JS -CLOBBER -xml jquery.xml
E:\Utilities\AjaxMinifier\AjaxMinifier.exe -CSS -CLOBBER -xml css.xml
pause > nul
暂停通常会被注释掉,但我需要看看发生了什么。
这是我的 css xml 文件
<root>
<output path="..\httpdocs\css\min\my.css">
<input path="..\httpdocs\css\raw\buttons.css"/>
<input path="..\httpdocs\css\raw\menustyles.css"/>
</output>
</root>
还有我的 jquery xml 文件
<root>
<output path="../httpdocs\js\min\mutual.js">
<input path="../httpdocs\js\raw\table_scroll.js"/>
<input path="../httpdocs\js\raw\mutual.js"/>
<input path="../httpdocs\js\raw\menudrop\menu_jquery.js"/>
</output>
</root>
谁能告诉我如何通过双击批处理文件将其加载到同一文件夹中的 xml 文件中?我不能使用固定路径。
【问题讨论】:
-
cd /d %\dp0将工作目录更改为批处理文件所在的文件夹。 (当你双击你的批处理文件时,它的工作目录是%windir%\system32)
标签: windows batch-file path