run_cmd
Execute CMD commands to automate Windows system tasks, manage processes, and perform file operations directly from the automation server.
Instructions
执行 CMD 命令
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| command | Yes | CMD 命令 | |
| timeout | No | 超时时间(毫秒,可选) |
Input Schema (JSON Schema)
{
"properties": {
"command": {
"description": "CMD 命令",
"type": "string"
},
"timeout": {
"description": "超时时间(毫秒,可选)",
"type": "number"
}
},
"required": [
"command"
],
"type": "object"
}
Implementation Reference
- src/tools/powershell.js:107-123 (handler)The main handler function for the 'run_cmd' tool. Executes the provided command using child_process.execAsync with cmd.exe shell, returning success/output/error or failure details.async runCmd(command, timeout = 30000) { try { const { stdout, stderr } = await execAsync(command, { shell: 'cmd.exe', timeout, maxBuffer: 1024 * 1024 * 10, }); return { success: true, output: stdout.trim(), error: stderr.trim(), command }; } catch (error) { return { success: false, error: error.message, command }; } }
- src/tools/powershell.js:24-35 (schema)Input schema for the 'run_cmd' tool, defining required 'command' string and optional 'timeout' number.{ name: 'run_cmd', description: '执行 CMD 命令', inputSchema: { type: 'object', properties: { command: { type: 'string', description: 'CMD 命令' }, timeout: { type: 'number', description: '超时时间(毫秒,可选)' }, }, required: ['command'], }, },
- src/tools/powershell.js:73-74 (registration)Registration/dispatch in executeTool method: maps 'run_cmd' tool name to the runCmd handler.case 'run_cmd': return await this.runCmd(args.command, args.timeout);
- src/tools/powershell.js:64-65 (registration)'run_cmd' listed as a supported tool in the canHandle method.const tools = ['run_powershell', 'run_cmd', 'get_system_info', 'get_disk_info', 'get_network_info'];