Search notes:

Debugging tools for Windows: scripting with JavaScript

The script

"use strict"

function invokeScript() {
   host.diagnostics.debugLog('Threads');
   var proc = host.currentProcess;
   for (var thr of proc.Threads) {
      host.diagnostics.debugLog("  " + thr + "\n");
   }
}
Github repository Windows-Debugging-Tools, path: /scripting/JavaScript/iterate-threads/script.js

Launch notepad and execute the script in it

start-process notepad

while($true) {
  #
  # Wait until notepad is started
  #
    $status = get-process notepad -errorAction silentlyContinue
    if (! $status) {
      start-sleep -milliSeconds 66
    }
    else {
      break
    }
}


#
#  Attach to process and run script
#  to display threads.
#
cdb -pn notepad.exe -c ".scriptrun script.js"
Github repository Windows-Debugging-Tools, path: /scripting/JavaScript/iterate-threads/launch-notepad-and-run-script.ps1

See also

Object model
Debugging tools for Windows: scripting

Index