如何创建适用于 Program Files 和 Program Files(x86) 的批处理文件? [英] How to create a batch file which work for both Program Files and Program Files(x86)?

查看:162
本文介绍了如何创建适用于 Program Files 和 Program Files(x86) 的批处理文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个批处理文件,它会自动将 .sql 文件复制到已安装的 Jasper 服务器的路径(可以是任何软件安装目录).

I have created a batch file which automatically copy a .sql file to the path of installed Jasper server(it could be any software installation directory).

这是我的批处理脚本--

This is my batch script--

C:PROGRA~2JASPER~1.0mysqlinmysql.exe -u root -proot <create_database.sql

C:PROGRA~2JASPER~1.0mysqlinmysql.exe -u root -proot < create_database.sql

在 Program Files(x86) 中安装 jasper 时工作.我如何将它概括为 Program Files 和 Program Files(x86).

that is working when jasper is installed in Program Files(x86). How can i generalize it for both Program Files and Program Files(x86).

推荐答案

您想使用环境变量来查找此类内容.在 32 位 Windows 上,%ProgramFiles% 是您的朋友.

You want to use environment variables to look up things like this. On 32bit Windows, %ProgramFiles% is your friend.

在 64 位 Windows 上,事情有点复杂,因为应用程序可以安装在 %ProgramFiles%%ProgramFiles(x86)% 中.

On 64bit Windows, things are a little more complicated, as application can be installed both in %ProgramFiles% and %ProgramFiles(x86)%.

如果您无法通过其他方式(注册表?已安装的程序设置?)查找 Jasper 的位置,那么最好的办法是在两个地方都查找并找到您想要的目录.

If you cannot look up the location of Jasper some other way (registry? installed program settings?), your best bet is to look in both places and take the one where you find the expected directory.

编辑看到 nsis 标签 - 您正在创建安装程序吗?在这种情况下,常量 $ProgramFiles 可能会有用.

Edit Saw the nsis tag - are you creating an installer? In that case the constant $ProgramFiles might be useful.

这篇关于如何创建适用于 Program Files 和 Program Files(x86) 的批处理文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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