Skip to content

wise-union/cmd-matrix

Repository files navigation

cmd-matrix - Multi-Window Batch Command Executor

cmd-matrix is a Windows utility that reads commands from a text file and executes them in multiple CMD windows arranged in a grid layout.

Features

  • πŸ“ File-Driven: Reads commands from text files, one command per line
  • πŸͺŸ Grid Layout: Automatically arranges CMD windows in a neat grid
  • ⚑ Parallel Execution: All windows execute their commands simultaneously
  • πŸ“ Comment Support: Supports adding comments in command files (line-starting # only)
  • 🎯 Smart Layout: Automatically calculates optimal grid size based on command count
  • πŸ”§ Compatibility Mode: Retains original window movement functionality

Quick Start

1. Create Command File

Create a text file (e.g., commands.txt) with one command per line to be executed in CMD windows:

echo Welcome to cmd-matrix! This is Window 1
dir C:\ /w
ipconfig /all
echo Current system info: && systeminfo | findstr /B /C:"OS" /C:"System"
ping google.com -n 4
tasklist | findstr "chrome"

2. Run the Program

cmd-matrix.exe --file commands.txt

The program will automatically create multiple CMD windows, each executing one line from the file.

Important Note: The program will wait for you to press Enter in the command line window before closing all created CMD windows. During this time, all windows remain open.

Command Line Parameters

Basic Syntax

cmd-matrix.exe [options] [parameters]

Available Options

Execution Flow: The program first reads and displays all commands, then creates the specified number of CMD windows, each executing the corresponding command. After creation, the program waits for you to press Enter in the command line window, then closes all created windows.

πŸ“„ File Mode (Main Function)

cmd-matrix.exe --file <filename> [rows] [cols]
  • --file: Specifies the text file containing commands
  • [rows]: Optional, number of grid rows (auto-calculated by default)
  • [cols]: Optional, number of grid columns (auto-calculated by default)

Examples:

# Use commands from file with auto-calculated layout
cmd-matrix.exe --file mycommands.txt

# Use commands from file with 2x3 grid
cmd-matrix.exe --file mycommands.txt 2 3

πŸ§ͺ Test Mode

cmd-matrix.exe --test [rows] [cols]
  • --test: Creates test windows without using a file
  • [rows]: Optional, number of grid rows (default 3)
  • [cols]: Optional, number of grid columns (default 3)

Examples:

# Create 3x3 test windows
cmd-matrix.exe --test

# Create 2x4 test windows
cmd-matrix.exe --test 2 4

πŸ“ Screen Resolution

cmd-matrix.exe --resolution

Displays current screen resolution information.

🎯 Window Movement Mode (Compatibility Mode)

cmd-matrix.exe "window_title" <x_coord> <y_coord> <width_chars> <height_chars>

Moves a window with the specified title to the specified position and size. This is the compatibility mode for the original win_sizer functionality.

Example:

# Move window containing "CMD" to (100,100) with size 80x25 characters
cmd-matrix.exe "CMD" 100 100 80 25

Note: This mode does not create new windows, it only moves existing windows.

Command File Format

Basic Format

  • One command per line
  • Commands execute in corresponding CMD windows
  • Empty lines are ignored

Comments

Lines starting with # are treated as comments and will not be executed:

# This is a comment
echo Hello World  # This is NOT a comment, # will be treated as part of the command

# System information query
echo System Information:
systeminfo | findstr /B /C:"OS"

# Network test
ping 8.8.8.8

Important: According to the code implementation, only lines starting with # are recognized as comments and skipped. # symbols within commands are not specially processed and are treated as part of the command.

Command File Examples

Example 1: System Information Query

# System Information
echo ===== System Information ===== && systeminfo | findstr /B /C:"OS" /C:"System"

# Network Configuration
echo ===== Network Configuration ===== && ipconfig /all

# Disk Space
echo ===== Disk Space ===== && wmic logicaldisk get size,freespace,caption

# Process List
echo ===== Running Processes ===== && tasklist | findstr /V "Console"

Example 2: Network Diagnostics

# Network Diagnostic Tools
# Test local network
echo Testing local gateway... && ping 192.168.1.1 -n 4

# Test DNS
echo Testing DNS server... && nslookup google.com

# Test internet connection
echo Testing internet connection... && ping google.com -n 4

# Display routing table
echo Displaying routing table... && route print

# Display network connections
echo Displaying network connections... && netstat -an

Example 3: Development Environment Check

# Development Environment Check
echo Node.js Version: && node --version

echo npm Version: && npm --version

echo Python Version: && python --version

echo Git Version: && git --version

echo Docker Status: && docker --version

Usage Tips

1. Auto Layout Calculation

If rows and columns are not specified, the program automatically selects the optimal layout based on command count:

  • 1-4 commands: 2Γ—2 grid
  • 5-6 commands: 2Γ—3 grid
  • 7-9 commands: 3Γ—3 grid
  • 10-12 commands: 3Γ—4 grid

Note: The actual number of windows created is the smaller of command count and grid size. For example, if you have 5 commands but specify a 2Γ—2 grid, only 4 windows will be created.

2. Command Output Redirection

You can save command output to files:

ipconfig /all > network_info.txt
dir C:\ > file_list.txt

3. Multi-Command Combination

You can combine multiple commands in one line using && or |:

echo Starting check && systeminfo && echo Check complete
dir C:\ | findstr "Directory"

4. Window Management

  • All windows open simultaneously and arrange on screen
  • Press Enter to close all windows (in the main program window)
  • Window title format: BATCH-CMD-X-WIN (X is window number)

FAQ

Q: What encoding is required for command files?

A: ANSI encoding or UTF-8 encoding (without BOM) is recommended.

Q: What if command execution fails?

A: Check if the command syntax is correct. You can test commands in a separate CMD window first.

Q: Can commands requiring administrator privileges be executed?

A: You need to run cmd-matrix.exe as administrator.

Q: What if windows are arranged chaotically?

A: Check screen resolution to ensure there's enough space for all windows.

Q: How to close all windows early?

A: Press Enter in the command line window where cmd-matrix is running to close all created CMD windows.

Notes

  1. Command Length Limit: Maximum 1024 characters per command
  2. Command Count Limit: Maximum 100 commands
  3. Window Count: Maximum 100 windows
  4. File Path: Use full path if command file is not in the same directory
  5. Special Characters: Use quotes when file path contains spaces
  6. Comment Rule: Only lines starting with # are recognized as comments, # in commands is treated as part of the command
  7. Closing Method: You can only close all windows by pressing Enter in the command line window where cmd-matrix is running, not in the created CMD windows
  8. Usage of AI: Most of the above content generated by AI.

About

cmd-matrix is a Windows utility that reads commands from a text file and executes them in multiple CMD windows arranged in a grid layout.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors