共用方式為


.scriptrun (執行腳本)

.scriptrun 命令將會載入並執行JavaScript。

.scriptrun ScriptFile  

參數

ScriptFile
指定要載入和執行的文稿檔名。 ScriptFile 應該包含擴展名.js。 可以使用絕對或相對路徑。 相對路徑與您啟動調試程式的目錄相對。 不支援包含空格的檔案路徑。

Environment

項目 說明
模式 使用者模式、核心模式
目標 即時、損毀傾印
平台 全部

其他資訊

.scriptrun 命令會載入腳本,並執行下列程序代碼。

  • intializeScript
  • invokeScript

載入和執行程式代碼時,會顯示確認訊息。

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

腳本所做的任何物件模型操作都會保持原狀,直到腳本後續卸除或以不同內容再次執行為止。

下表摘要說明 .scriptload 和 .scriptrun 會執行哪些函式。

.scriptload .scriptrun
initializeScript
invokeScript
uninitializeScript

您可以使用此程式碼來檢視使用 .script run 命令呼叫哪些函式。

// 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");
}

如需使用 JavaScript 的詳細資訊,請參閱 JavaScript 調試程式腳本。 如需調試程式對象的詳細資訊,請參閱 JavaScript 延伸模組中的原生物件。

需求

使用任何 .script 命令之前,必須載入腳本提供者。 使用 .load (載入延伸模組 DLL) 命令來載入 JavaScript 提供者 dll。

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

另請參閱

.scriptload (載入腳本)

JavaScript 調試程式腳本