# RunBat **Repository Path**: yanzhoupuzhang/run-bat ## Basic Information - **Project Name**: RunBat - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2025-09-26 - **Last Updated**: 2025-09-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # RunBat ## 项目介绍 RunBat是一款集成了UniApp前端和C++后端的批处理脚本执行工具,为用户提供了便捷的BAT脚本创建、管理和执行环境。 RunBat is a batch script execution tool that integrates UniApp frontend and C++ backend, providing users with a convenient environment for creating, managing and executing BAT scripts. 以下是软件的主界面截图: The following is a screenshot of the software's main interface: ![RunBat界面截图](pic.png) ## 功能特点 - **图形化界面**:基于UniApp开发的现代化界面,支持脚本的创建、编辑和保存 - **脚本执行**:安全执行批处理脚本并展示执行结果 - **脚本管理**:保存、加载和删除常用脚本 - **跨平台前端**:UniApp框架支持多端部署 - **高性能后端**:C++实现的后端确保脚本执行的高效性 ## 项目结构 项目主要由两部分组成: 1. **UniApp前端**:位于`uniapp/runBat/`目录 2. **C++后端**:位于`vs2017/RunBat/`目录 编译后的发布文件位于`Release/`目录,包括可执行文件和相关资源。 ## 技术架构 ### 前端架构 - **框架**:UniApp (Vue.js) - **UI组件**:基于UniApp内置组件 - **构建工具**:UniApp CLI ### 后端架构 - **开发环境**:Visual Studio 2017 - **框架**:Chromium Embedded Framework (CEF) - **JSON处理**:nlohmann/json库 - **核心功能**: - `RunBatScript`类:负责执行BAT脚本 - `dataBatScript`命名空间:负责脚本数据的持久化 ## 核心功能实现 ### 脚本执行 `RunBatScript`类提供了执行BAT脚本的核心功能: 1. 处理输入的脚本内容,移除暂停命令 2. 编码转换,确保脚本正确执行 3. 创建临时批处理文件 4. 执行脚本并捕获输出 5. 清理临时文件并返回结果 ```cpp // 执行BAT脚本的核心方法 extern std::string RunBatScript::runBatScript(std::string& batContent) { // 处理脚本内容 // 创建临时批处理文件 // 执行脚本并捕获输出 // 返回执行结果 } ``` ### 数据管理 `dataBatScript`命名空间提供了脚本的保存、加载和删除功能: - `save()`:保存脚本到数据文件 - `loadAll()`:加载所有已保存的脚本 - `del()`:删除指定名称的脚本 所有脚本数据保存在`bat_scripts.json`文件中。 ### CEF集成 项目使用Chromium Embedded Framework (CEF)来提供Web界面支持,主要组件包括: - `SimpleApp`:CEF应用程序主类 - `SimpleHandler`:处理浏览器事件和生命周期 ## 编译与运行 ### 前端编译 1. 确保已安装HBuilderX或UniApp CLI 2. 打开`uniapp/runBat/`目录 3. 执行编译命令或在HBuilderX中点击运行/发行按钮 ### 后端编译 1. 使用Visual Studio 2017打开`vs2017/RunBat/RunBat.sln`解决方案 2. 选择目标平台(Win32/x64)和配置(Debug/Release) 3. 构建解决方案 ### 运行应用 编译完成后,可在`Release/`目录下找到`RunBat.exe`文件,直接运行即可启动应用程序。 ## 注意事项 1. 程序需要管理员权限才能执行某些系统级命令 2. 脚本执行可能会对系统产生影响,请谨慎编写和执行脚本 3. 程序运行时会在临时目录创建临时文件,执行完成后会自动清理 ## License [MIT](LICENSE) --- # RunBat (English Version) ## Project Introduction RunBat is a batch script execution tool that integrates UniApp frontend and C++ backend, providing users with a convenient environment for creating, managing and executing BAT scripts. ## Features - **Graphical Interface**: Modern interface developed based on UniApp, supporting script creation, editing and saving - **Script Execution**: Safely execute batch scripts and display execution results - **Script Management**: Save, load and delete frequently used scripts - **Cross-platform Frontend**: UniApp framework supports multi-end deployment - **High-performance Backend**: C++-implemented backend ensures efficient script execution ## Project Structure The project mainly consists of two parts: 1. **UniApp Frontend**: Located in the `uniapp/runBat/` directory 2. **C++ Backend**: Located in the `vs2017/RunBat/` directory Compiled release files are located in the `Release/` directory, including executable files and related resources. ## Technical Architecture ### Frontend Architecture - **Framework**: UniApp (Vue.js) - **UI Components**: Based on UniApp built-in components - **Build Tools**: UniApp CLI ### Backend Architecture - **Development Environment**: Visual Studio 2017 - **Framework**: Chromium Embedded Framework (CEF) - **JSON Processing**: nlohmann/json library - **Core Functions**: - `RunBatScript` class: Responsible for executing BAT scripts - `dataBatScript` namespace: Responsible for script data persistence ## Core Function Implementation ### Script Execution The `RunBatScript` class provides the core functionality for executing BAT scripts: 1. Process input script content and remove pause commands 2. Perform encoding conversion to ensure correct script execution 3. Create temporary batch files 4. Execute scripts and capture output 5. Clean up temporary files and return results ```cpp // Core method for executing BAT scripts extern std::string RunBatScript::runBatScript(std::string& batContent) { // Process script content // Create temporary batch files // Execute scripts and capture output // Return execution results } ``` ### Data Management The `dataBatScript` namespace provides functions for saving, loading and deleting scripts: - `save()`: Save script to data file - `loadAll()`: Load all saved scripts - `del()`: Delete script with specified name All script data is stored in the `bat_scripts.json` file. ### CEF Integration The project uses Chromium Embedded Framework (CEF) to provide web interface support. Main components include: - `SimpleApp`: CEF application main class - `SimpleHandler`: Handle browser events and lifecycle ## Compilation and Running ### Frontend Compilation 1. Ensure HBuilderX or UniApp CLI is installed 2. Open the `uniapp/runBat/` directory 3. Execute the compilation command or click the run/publish button in HBuilderX ### Backend Compilation 1. Open the `vs2017/RunBat/RunBat.sln` solution using Visual Studio 2017 2. Select the target platform (Win32/x64) and configuration (Debug/Release) 3. Build the solution ### Running the Application After compilation is complete, you can find the `RunBat.exe` file in the `Release/` directory, and run it directly to start the application. ## Notes 1. Administrator privileges are required to execute certain system-level commands 2. Script execution may affect the system, please write and execute scripts with caution 3. The program creates temporary files in the temporary directory during runtime, which will be automatically cleaned up after execution ## License [MIT](LICENSE)