简体   繁体   English

NSIS获取呼叫者文件路径

[英]NSIS get caller file path

I have an altered Java Launcher exe file written in NSIS that launches a JAR file ( http://nsis.sourceforge.net/A_slightly_better_Java_Launcher ). 我有一个用NSIS编写的经过修改的Java Launcher exe文件,它可以启动JAR文件( http://nsis.sourceforge.net/A_slightly_better_Java_Launcher )。 I want to pass into the JAR a parameter, that parameter being the absolute path of the file which called the exe. 我想将一个参数传递到JAR中,该参数是称为exe的文件的绝对路径。

In a BAT file I can use "start MyApp.jar %1" and that fills in the abs path, but that cannot be done in NSIS it seems (or I am not writing it correctly cause my parameter comes in literally as "%1"). 在BAT文件中,我可以使用“ start MyApp.jar%1”并填充abs路径,但这似乎无法在NSIS中完成(或者我没有正确编写它,这是因为我的参数字面意思是“%1” ”)。

I want my command to be: javaw -jar MyApp.jar AbsolutePath 我希望我的命令是:javaw -jar MyApp.jar AbsolutePath

Here is my line currently that I want that path added to: 这是我当前要将该路径添加到的行:

StrCpy $0 '"$R0" -jar "${JAR}"' StrCpy $ 0'“ $ R0” -jar“ $ {JAR}”'

Any suggestions would be appreciated. 任何建议,将不胜感激。 Thanks. 谢谢。

%1 does not have to be the absolute path, it's just the first parameter, it could also be a relative path (Or not a path at all) %1不必是绝对路径,它只是第一个参数,也可以是相对路径(或者根本不是路径)

In this case, using ${GetParameters} from FileFunc.nsh should fit your needs even though it gives you every parameter, not just the first one 在这种情况下,使用FileFunc.nsh中的$ {GetParameters}应该可以满足您的需求,即使它可以为您提供每个参数,而不仅仅是第一个

Here is the line which is put into the "open" command for my file extension. 这是放在我的文件扩展名的“打开”命令中的行。 In register R7 I placed the path to "javaw.exe". 在寄存器R7中,我将路径放置到“ javaw.exe”。 That method (called GetJRE) is in the link inside my question. 该方法(称为GetJRE)在我的问题的链接中。 Windows itself then fills in the parameter of the file calling my jar and passes it as a parameter. Windows本身然后填写调用我的jar的文件的参数,并将其作为参数传递。

${registerExtension} "$R7$\\" -jar -Djava.library.path=$\\"$INSTDIR$\\" $\\"$INSTDIR\\Viewer.jar" ".YourExtension" "YourExtension File" $ {} registerExtension “$ R7 $ \\” 罐子-Djava.library.path = $ \\ “$ INSTDIR $ \\” $ \\ “$ INSTDIR \\ Viewer.jar” “.YourExtension” “YourExtension文件”

${unregisterExtension} ".YourExtension" "YourExtension File" $ {unregisterExtension}“ .YourExtension”“ YourExtension文件”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM