0

I work for a local council that for some reason has purchased an application that is very flaky when using Java. Certain web screens will not launch and the only way I have found to resolve the problem is to open up the Java Console and then immediately close it without doing anything else. Unfortunately, I have been told that this is not a satisfactory fix when hundreds of people are going to be using the system. I have written a batch file that will open & close the console prior to opening the IE URL(see below).

Start /wait "" "C:\Program Files\Java\jre6\bin\javacpl.exe"  
ECHO Opening JAVA Console  
timeout 4  
TASKKILL /F /IM javacpl.exe

Then problem with this is that it kills any and every session of Java that is running on the PC not just the console. Therefore people are unable to run multiple versions of the application ie Test, Dev, Train and/or Live. Is there a way of just closing the console but leave all other instances of java running?

Thanks

1

1 Answer 1

0

If you look at the taskkill command, you can see the taskkill switches:

TASKKILL [/S system [/U username [/P [password]]]]
         { [/FI filter] [/PID processid | /IM imagename] } [/T] [/F]

Description:
    This tool is used to terminate tasks by process id (PID) or image name.

Parameter List:
    /S    system           Specifies the remote system to connect to.

    /U    [domain\]user    Specifies the user context under which the
                           command should execute.

    /P    [password]       Specifies the password for the given user
                           context. Prompts for input if omitted.

    /FI   filter           Applies a filter to select a set of tasks.
                           Allows "*" to be used. ex. imagename eq acme*

    /PID  processid        Specifies the PID of the process to be terminated.
                           Use TaskList to get the PID.

    /IM   imagename        Specifies the image name of the process
                           to be terminated. Wildcard '*' can be used
                           to specify all tasks or image names.

    /T                     Terminates the specified process and any
                           child processes which were started by it.

    /F                     Specifies to forcefully terminate the process(es).

    /?                     Displays this help message.

Filters:
    Filter Name   Valid Operators           Valid Value(s)
    -----------   ---------------           -------------------------
    STATUS        eq, ne                    RUNNING |
                                            NOT RESPONDING | UNKNOWN
    IMAGENAME     eq, ne                    Image name
    PID           eq, ne, gt, lt, ge, le    PID value
    SESSION       eq, ne, gt, lt, ge, le    Session number.
    CPUTIME       eq, ne, gt, lt, ge, le    CPU time in the format
                                            of hh:mm:ss.
                                            hh - hours,
                                            mm - minutes, ss - seconds
    MEMUSAGE      eq, ne, gt, lt, ge, le    Memory usage in KB
    USERNAME      eq, ne                    User name in [domain\]user
                                            format
    MODULES       eq, ne                    DLL name
    SERVICES      eq, ne                    Service name
    WINDOWTITLE   eq, ne                    Window title

    NOTE
    ----
    1) Wildcard '*' for /IM switch is accepted only when a filter is applied.
    2) Termination of remote processes will always be done forcefully (/F).
    3) "WINDOWTITLE" and "STATUS" filters are not considered when a remote
       machine is specified.

Examples:
    TASKKILL /IM notepad.exe
    TASKKILL /PID 1230 /PID 1241 /PID 1253 /T
    TASKKILL /F /IM cmd.exe /T 
    TASKKILL /F /FI "PID ge 1000" /FI "WINDOWTITLE ne untitle*"
    TASKKILL /F /FI "USERNAME eq NT AUTHORITY\SYSTEM" /IM notepad.exe
    TASKKILL /S system /U domain\username /FI "USERNAME ne NT*" /IM *
    TASKKILL /S system /U username /P password /FI "IMAGENAME eq note*"

You might be able to use TASKKILL /FI "Windows title" to kill the specific instance you are having issues with.

You could also do essentially the same thing in PowerShell, but there are other potential routes to try and guess better.

For example, you could see what the running time of various Java.exes are and kill only the right one:

Get-Process -Name "java" | where {$_.Starttime -lt 100}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .