简体   繁体   中英

Pass arguments to already running nsis java launcher

Am using nsis for launching my java application. I wanted to show a window once the application is launched. I can pass a command line argument while launching the java application like this.

OutFile "Test.exe"
....
ExecWait javaw.exe -jar myapp.jar
SectionEnd

Now I would like to show the default window of the already running java application if another instance of the nsis launcher is invoked. In order to do this I need to pass an argument to my java application. For this to happen I have to pass the argument to the cmd window(internally used by NSIS) of the already running instance.

How would I accomplish this?

I'm not sure I understand you correctly but you can use this example to create a mutex for the nsis installer. The example there will bring to front the already running installer, you can change it a bit to bring to front the running java window, if you know its handle or title.

     System::Call "kernel32::CreateMutexA(i 0, i 0, t 'my_mutex') i .r0 ?e"
     Pop $0
     StrCmp $0 0 launch
     FindWindow $1 "my window class" "my window title"
     IntCmp $1 0 bring_front end
     bring_front:
     System::Call "user32::SetForegroundWindow(i r1) i."
     end:
     Abort
     launch:

If you have Spy++ (which comes with Microsoft Visual Studio) you can find the window class of your java app.

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