简体   繁体   中英

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 ). I want to pass into the JAR a parameter, that parameter being the absolute path of the file which called the 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").

I want my command to be: javaw -jar MyApp.jar AbsolutePath

Here is my line currently that I want that path added to:

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)

In this case, using ${GetParameters} from FileFunc.nsh should fit your needs even though it gives you every parameter, not just the first one

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". That method (called GetJRE) is in the link inside my question. Windows itself then fills in the parameter of the file calling my jar and passes it as a parameter.

${registerExtension} "$R7$\\" -jar -Djava.library.path=$\\"$INSTDIR$\\" $\\"$INSTDIR\\Viewer.jar" ".YourExtension" "YourExtension File"

${unregisterExtension} ".YourExtension" "YourExtension File"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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