This skill helps Windows 11 users, viabatch scripts (.bat) , launch programs or batch-launch programs with one click, and forcibly close programs.
Use Cases
- Need to write a batch script on Win11 to launch one or more programs
- Need to launch multiple programs with one click simultaneously (such as screen recording tools, auxiliary tools, etc.)
- Need to forcibly close specified programs with one click
- Create one-click start/stop scripts for "demo/screen recording/development environments"
Core Syntax
1. Launch a program
start /d "程序的所在目录完整路径" 程序名.exe
start— Launches a new window to run the program/d— Specifies the program'sstarting working directory(the current directory when the program runs)- followed by the
.exefilename to execute
Note: If the program path is not in the system PATH, be sure to use /d to specify the directory, otherwise dependency files may not be found.
2. Forcibly close a program
taskkill /f /im 程序名.exe
taskkill— Terminates the process/f— Force termination (does not wait for the program to respond)/im— Matches by image name (i.e., process name)
Complete Example: One-Click Start/Stop for Multiple Programs
The following is a real "recording demo video auxiliary tool" script; it first launches three tools, then the lower half closes them all with one click:
@echo off
chcp 65001 >nul
:: ====== 启动程序 ======
start /d "D:\software\PointerFocus\pointerfocus2.4\PointerFocus" PointerFocus.exe
start /d "C:\Users\Administrator\AppData\Local\carnac" Carnac.exe
start /d "D:\software\obs\obs-studio\bin\64bit" obs64.exe
echo 所有程序已启动!
pause
:: ====== 关闭程序 ======
taskkill /f /im obs64.exe
taskkill /f /im PointerFocus.exe
taskkill /f /im Carnac.exe
echo 所有程序已关闭!
pause
@echo offTurn off command echoing,chcp 65001 >nulset the console encoding to UTF-8 to prevent garbled Chinese characters,pausekeep the window open waiting for a key press.
Principles for Generating Scripts
When generating scripts for Win11 users, follow these principles:
- Always start with
@echo offbegin with, keeping the output clean - Add
chcp 65001 >nulto prevent garbled Chinese characters - Wrap paths in double quotes, to prevent errors with paths containing spaces
- Split launching and closing into two sections, separated by
::comments - Use the
.batextension (best compatibility, runs directly with a double-click on Win11) - If you are unsure of the directory where a program is located, you can suggest the user locate it using "Open file location" in the Win11 Task Manager
- Always put the close script later in the same file, separated by
pause, so users can launch first and close everything with one click when done
Interacting with the User
When the user requests "launch a program" or "batch launch":
- First ask which programs to launch and their respective installation paths
- If the user only provides program names without paths, you can suggest several ways to locate the paths:
- Start menu → right-click the program → Open file location
- Task Manager → find the process → right-click → Open file location
where 程序名command (only works for programs in PATH)
- Generate a
.batscript for the user, placed in a convenient location (such as the desktop or project directory) - Remind the user: double-click
.batto run; right-click to "Run as administrator" (some programs require administrator privileges)