jstack can only click on a process starting with the same user in the same session . When no session is specified, the psexec command is delayed in the console session and throws this error when trying to get a stream dump.
the solution is to ensure that the user and session used with psexec are the same as for the target Java process.
if it was started by a regular user as well. use the same user credentials to log in without the -s or -h sign b. find the identifier of the session in which the process was started. (You can find it using the task manager and go to the "Users" tab). Use this session identifier with the -i flag
psexec \\server-name -u username -p password -i session-id command
eg.
psexec \\192.168.1.1 -u john -p pass123 -i 1 jstack.exe 4242
Note. If the java process was started by the user SYSTEM, use the -s flag
source share