Επεξεργασία

Κοινή χρήση μέσω


.scriptrun (Run Script)

The .scriptrun command will load and run a JavaScript.

.scriptrun ScriptFile  

Parameters

ScriptFile
Specifies the name of the script file to load and execute. ScriptFile should include the .js file name extension. Absolute or relative paths can be used. Relative paths are relative to the directory that you started the debugger in. File paths containing spaces are not supported.

Environment

Item Description
Modes User mode, kernel mode
Targets Live, crash dump
Platforms All

Additional Information

The .scriptrun command will load a script and, execute the following code.

  • root
  • intializeScript
  • invokeScript

A confirmation message is displayed when the code is loaded and executed.

0:000> .scriptrun C:\WinDbg\Scripts\helloWorld.js
JavaScript script successfully loaded from 'C:\WinDbg\Scripts\helloWorld.js'
Hello World!  We are in JavaScript!

Any object model manipulations made by the script will stay in place until the script is subsequently unloaded or is run again with different content.

This table summarizes which functions are executed by .scriptload and .scriptrun.

.scriptload .scriptrun
root yes yes
initializeScript yes yes
invokeScript yes
uninitializeScript

You can use this code to see which functions are called with the .script run command.

// Root of Script
host.diagnostics.debugLog("***>; Code at the very top (root) of the script is always run \n");


function initializeScript()
{
    // Add code here that you want to run every time the script is loaded. 
    // We will just send a message to indicate that function was called.
    host.diagnostics.debugLog("***>; initializeScript was called \n");
}

function invokeScript()
{
    // Add code here that you want to run every time the script is executed. 
    // We will just send a message to indicate that function was called.
    host.diagnostics.debugLog("***>; invokeScript was called \n");
}

For more information about working with JavaScript, see JavaScript Debugger Scripting. For more information about the debugger objects, see Native Objects in JavaScript Extensions.

Requirements

Before using any of the .script commands, a scripting provider needs to be loaded. Use the .load (Load Extension DLL) command to load the JavaScript provider dll.

0:000> .load C:\ScriptProviders\jsprovider.dll

See also

.scriptload (Load Script)

JavaScript Debugger Scripting