NSIS - 在运行之前设置进程的工作目录 [英] NSIS - Set the working directory for a process before running it

查看:190
本文介绍了NSIS - 在运行之前设置进程的工作目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如上所述。
我通过调用java.exe并传递类名,使用ExecWait专门运行Java程序。我正在运行的应用程序依赖于相对路径,必须从特定目录运行,但是当我直接调用java时,它只是使用安装程序位置作为当前目录而失败。

As above. I'm specifically running a Java program using ExecWait, by invoking java.exe and passing the classname. The application I'm running relies on relative paths and has to be run from a specific directory, however when I directly call java, it simply uses the installer location as the current directory and fails.

有没有办法解决这个问题?

Is there a way to get around this?

更新:这是我的命令行:

ExecWait "$INSTDIR\MyApp\jre\bin\java.exe -cp $INSTDIR\MyApp\lib\*; MyJavaClassName"


推荐答案

< a href =http://anders_k.users.sourceforge.net/public/NSIS/2.46/Manual.html#setoutpath> SetOutPath 设置进程的当前/工作目录,它应该由子进程...

SetOutPath sets the current/working directory for the process, it should be inherited by the child process...

Push $OUTDIR
SetOutPath $myspecialdir
ExecWait '"$instdir\myapp.exe"'
Pop $OUTDIR
SetOutPath $OUTDIR # Optional if working directory does not matter for the rest of the code

SetOutPath $myspecialdir
ExecWait '"$instdir\myapp.exe"'
SetOutPath $instdir

这篇关于NSIS - 在运行之前设置进程的工作目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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