Windows 路径变量
我的程序需要 .bat 文件才能运行,因为 .bat 文件正在更改某些语言设置,因此 .bat 文件如下所示:
set lang=en
start ap.exe
它工作得很好,但是当我为我的 app
制作安装程序并指向 .bat 文件时作为主文件,它会在桌面上创建该 .bat 文件的快捷方式。到目前为止,一切都很好,但是当我启动该快捷方式时,它无法打开 app.exe,因为它在桌面上找不到它。
所以我的问题是:如何获取 .bat 文件的文件夹路径,以便设置正确的启动命令?像这样的东西:
设置 lang=zh
S=getpath();
启动S/app.exe
这只是伪代码,但我认为你明白了。
My program needs .bat file to run because the .bat file is changing some language settings, so .bat file looks like:
set lang=en
start ap.exe
It is working great but when I made installer for my app
and pointed .bat file as main file, it creates a shortcut on the desktop to that .bat file. So far everything is great but when I launch that shortcut it cannot open app.exe because it can't find it on desktop.
So my question is: How can I get path to folder of .bat file so I could set proper start command? Something like:
set lang=en
S=getpath();
start S/app.exe
It is just pseudocode but I think you get point.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以编写
%~dp0
来获取包含批处理文件的目录。因此,你可以写
You can write
%~dp0
to get the directory containing the batch file.Therefore, you can write