Detecting an already running Java application from NSIS

℡╲_俬逩灬. 提交于 2019-12-06 13:45:42

问题


Yes, it's well documented how to get the name of your application's exe file and see if it is running. When the application in question is a java application, the running exe will always be java.exe, and so this method falls flat on its face since there could be any number of java applications currently running, all launched with java.exe. Each one will differ in the commandline parameters passed, including the main class name.

I need to know the commandline parameters to java.exe so I can know that only the one that says java.exe MyProgram is to be terminated.

How do I do that in NSIS?


回答1:


I use the FindWindow command. This assumes that the different Java applications have different window titles.

Edited to add: While the window class is a required parameter, the empty string (any window class) is a valid window class parameter. Here's a complete FindWindow function from one of my NSIS installers:

Function filzip_check
    filzip_check_start:
        ClearErrors
        FindWindow $5 "" "FilZip"
        StrCmp $5 "0" filzip_check_end +1
        MessageBox MB_OK "Please close any FilZip windows before continuing \
                the install"
        Goto filzip_check_start
    filzip_check_end:
FunctionEnd



回答2:


The command jps -v will give you the command line parameters to the running Java processes.



来源:https://stackoverflow.com/questions/8431909/detecting-an-already-running-java-application-from-nsis

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!