Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>Script Runner TerminalNew to Visual Studio Code? Get it now.
Script Runner Terminal

Script Runner Terminal

Jimmy Ben

|
3 installs
| (0) | Free
在 VS Code 中运行 bat、cmd、ps1、py、js、ts、java、jar、php、rb、go、lua、rs 等脚本或可执行源码文件,支持替换运行、新开集成终端运行和新开系统窗口运行。
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Script Runner Terminal

Script Runner Terminal is a VS Code extension for quickly running script files directly from the editor.

中文说明 | English

中文说明

Script Runner Terminal 是一个在 VS Code 中快速运行脚本文件的扩展。 它支持直接运行当前编辑器中的文件,并提供三种运行模式:

  • 替换运行:关闭当前文件之前由本扩展创建的终端,再重新运行
  • 新开终端运行:保留已有终端,并新开一个集成终端运行
  • 新开系统窗口运行:新开一个系统命令窗口运行当前文件

支持的文件类型

  • .bat
  • .cmd
  • .ps1
  • .py
  • .js
  • .ts
  • .java
  • .jar
  • .php
  • .rb
  • .go
  • .lua
  • .rs

快捷键

  • F5 运行当前脚本,并替换该文件上一次由本扩展启动的终端

  • Ctrl+F5 运行当前脚本,并保留已有终端,同时新开一个 VS Code 集成终端

  • Ctrl+Shift+F5 运行当前脚本,并新开一个系统命令窗口

命令面板

可以在命令面板中执行以下命令:

  • Script Runner Terminal: 运行当前脚本(替换上次运行)
  • Script Runner Terminal: 运行当前脚本(新开终端)
  • Script Runner Terminal: 运行当前脚本(新开系统窗口)

运行方式

  • .bat / .cmd 使用 cmd.exe 执行

  • .ps1 使用 powershell.exe -NoExit -ExecutionPolicy Bypass 执行

  • .py 优先使用 py -3,不可用时回退到 python

  • .js 使用 node

  • .ts 优先使用 tsx,不可用时回退到 npx tsx

  • .java 先执行 javac 编译,再执行 java

  • .jar 使用 java -jar

  • .php 使用 php

  • .rb 使用 ruby

  • .go 使用 go run

  • .lua 使用 lua

  • .rs 如果当前目录或上级目录存在 Cargo.toml,则使用 cargo run;否则使用 rustc 编译单文件后直接运行

注意事项

  • 只有当前活动文件是本地已保存文件时,扩展才会接管快捷键
  • 运行前会自动保存当前文件;如果保存失败,则不会执行
  • 扩展只会管理自己创建的终端,不会关闭你手动打开的终端
  • F5 只会替换“当前这个文件”之前由扩展创建的终端,不影响其他文件

环境要求

不同文件类型依赖本机已安装的运行时或工具链:

  • .py 需要 py 或 python
  • .js 需要 node
  • .ts 需要 tsx,或项目内可通过 npx tsx 调用
  • .java / .jar 需要 javac / java
  • .php 需要 php
  • .rb 需要 ruby
  • .go 需要 go
  • .lua 需要 lua
  • .rs 需要 cargo 或 rustc

English

Script Runner Terminal is a VS Code extension that lets you run script files quickly from the active editor. It supports three run modes:

  • Replace run: closes the previous terminal created by this extension for the current file, then runs again
  • Run in new terminal: keeps existing terminals and opens a new integrated terminal
  • Run in external window: opens a new system command window to run the current file

Supported File Types

  • .bat
  • .cmd
  • .ps1
  • .py
  • .js
  • .ts
  • .java
  • .jar
  • .php
  • .rb
  • .go
  • .lua
  • .rs

Keyboard Shortcuts

  • F5 Runs the current script and replaces the previous terminal started by this extension for the same file

  • Ctrl+F5 Runs the current script in a new VS Code integrated terminal while keeping existing terminals

  • Ctrl+Shift+F5 Runs the current script in a new system command window

Command Palette

You can also run these commands from the Command Palette:

  • Script Runner Terminal: Run Active Script (Replace Previous Run)
  • Script Runner Terminal: Run Active Script (New Terminal)
  • Script Runner Terminal: Run Active Script (External Window)

Execution Rules

  • .bat / .cmd Executed with cmd.exe

  • .ps1 Executed with powershell.exe -NoExit -ExecutionPolicy Bypass

  • .py Uses py -3 first, and falls back to python if needed

  • .js Executed with node

  • .ts Uses tsx first, and falls back to npx tsx if needed

  • .java Compiles with javac first, then runs with java

  • .jar Executed with java -jar

  • .php Executed with php

  • .rb Executed with ruby

  • .go Executed with go run

  • .lua Executed with lua

  • .rs Uses cargo run when a Cargo.toml exists in the current or parent directory; otherwise compiles the single file with rustc and runs the generated executable

Notes

  • The shortcuts are only active when the current file is a saved local file
  • The extension saves the current file before running; if saving fails, execution is cancelled
  • The extension only manages terminals created by itself and does not close terminals opened manually
  • F5 only replaces the previous terminal associated with the current file and does not affect terminals for other files

Requirements

Different file types depend on the corresponding runtime or toolchain being installed on your machine:

  • .py requires py or python
  • .js requires node
  • .ts requires tsx, or npx tsx available in the project
  • .java / .jar require javac / java
  • .php requires php
  • .rb requires ruby
  • .go requires go
  • .lua requires lua
  • .rs requires cargo or rustc
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft