title: jdk1.6 JMAP.EXE: Remote thread failed for unknown reason
body: <p>I get this error when using the following batch file to take a core dump of a Java service running in a Windows console shell:</p>
  
  <pre><code>The parent directory name of this script is: MyDIR
  Install dir is: C::\InstallDIR    
  The process id of window called MyDIR is 520
  Taking core dump... please wait...
  C::\InstallDIR\Javasoft\bin\jmap.exe -dump:file=heap.bin 520
  Dumping heap to C:\InstallDIR\MyDIR\heap.bin ...
  Exception in thread "main" java.lang.InternalError: Remote thread failed for 
    unknown reason
          at sun.tools.attach.WindowsVirtualMachine.enqueue(Native Method)
          at sun.tools.attach.WindowsVirtualMachine.execute(WindowsVirtualMachine.java:78)
          at sun.tools.attach.HotSpotVirtualMachine.executeCommand(HotSpotVirtualMachine.java:195)
          at sun.tools.attach.HotSpotVirtualMachine.dumpHeap(HotSpotVirtualMachine.java:162)
          at sun.tools.jmap.JMap.dump(JMap.java:224)
          at sun.tools.jmap.JMap.main(JMap.java:122)
  Press any key to continue . . .
  </code></pre>
  
  <p>And here is the script (-XX:OnError="script.bat") :</p>
  
  <pre><code>@echo off
  setlocal
  set PATH=%PATH%;C:\InstallDIR\Javasoft\jre\bin\server
  for /F "tokens=2,3,4,5,6,7 delims=\" %%i in ('cd') do (
    set i=%%i
    set j=%%j
    set k=%%k
    set l=%%l
    set m=%%m
    set n=%%n
  )
  set HOME=%i%
  if not "%i%" == "" (set SITE=%i%
  ) else (goto end:)
  if not "%j%" == "" (set SITE=%j%
  ) else (goto end:)
  if not "%k%" == "" (set SITE=%k%
  ) else (goto end:)
  if not "%l%" == "" (set SITE=%l%
  ) else (goto end:)
  if not "%m%" == "" (set SITE=%m%
  ) else (goto end:)
  if not "%n%" == "" (set SITE=%n%
  ) else (goto end:)
  :end
  echo The parent directory name of this script is: %SITE%
  echo Install dir is: %HOMEDRIVE%:\%HOME%
  echo.
  
  :: kill process using window TITLE to find PID
  FOR /F "tokens=2" %%I in ('TASKLIST /NH /FI "WINDOWTITLE eq %SITE%"' ) DO SET PID=%%I
  ECHO The process id of window called %SITE% is %PID%
  ECHO Taking core dump... please wait...
  %HOMEDRIVE%\%HOME%\Javasoft\bin\jmap.exe -dump:format=b,file=heap.bin %PID%
  ECHO Killing JVM %PID%...
  TASKKILL /PID %PID%
  :: then , restart server
  .\startServer.bat    
  ping -n 12 127.0.0.1&gt;nul
  if ERRORLEVEL == 0 (
    exit
  ) else (
    pause
  )
  </code></pre>
  
  <p>I can run jconsole.exe , attach to the process and dump the core easily.  Why isn't this as easy from the command line?  I know that the linux version of JMap has more options and capabilities.  Is this what I am running into here: a situation where the windows version of JMap just isn't able to do this simple thing?</p>