BAT脚本中的相对路径 [英] relative path in BAT script

查看:1629
本文介绍了BAT脚本中的相对路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我在USB驱动器上的程序文件夹:

Here is my own program folder on my USB drive:

Program\
     run.bat
     bin\
         config.ini
         Iris.exe
         library.dll
         etc.

我想使用run.bat来启动Iris.exe

我不能使用它:F:/Program/bin/Iris.exe就像快捷方式一样,因为有时它不作为驱动器F:(例如 E:G:)

I cannot use this: F:/Program/bin/Iris.exe like a shortcut, because sometimes it does not attach as drive F: (e.g. E: or G:)

无论驱动器盘符如何工作,我都需要在bat文件中写什么?

What do I need to write in the bat file to work regardless of the drive letter?

我在BAT文件中尝试过此操作

I tried this in the BAT file:

"\bin\Iris.exe"

但是它不起作用.

推荐答案

在批处理文件中使用它:

Use this in your batch file:

%~dp0\bin\Iris.exe

%~dp0解析为批处理脚本所在的文件夹的完整路径.

%~dp0 resolves to the full path of the folder in which the batch script resides.

这篇关于BAT脚本中的相对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆