launch_application
Launch applications on Windows systems by specifying the executable path, with options for command-line arguments and waiting for process completion.
Instructions
启动应用程序
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | 应用程序路径或命令 | |
| args | No | 命令行参数(可选) | |
| wait | No | 是否等待程序结束(可选) |
Input Schema (JSON Schema)
{
"properties": {
"args": {
"description": "命令行参数(可选)",
"items": {
"type": "string"
},
"type": "array"
},
"path": {
"description": "应用程序路径或命令",
"type": "string"
},
"wait": {
"description": "是否等待程序结束(可选)",
"type": "boolean"
}
},
"required": [
"path"
],
"type": "object"
}
Implementation Reference
- src/tools/process.js:81-95 (handler)The primary handler function implementing the launch_application tool. It constructs a command from the appPath and args, then uses execAsync if wait is true or spawn otherwise, returning success status and relevant output or error.async launchApplication(appPath, args = [], wait = false) { try { const command = args.length > 0 ? `"${appPath}" ${args.join(' ')}` : `"${appPath}"`; if (wait) { const { stdout, stderr } = await execAsync(command); return { success: true, path: appPath, output: stdout, error: stderr }; } else { spawn(command, { shell: true, detached: true, stdio: 'ignore' }).unref(); return { success: true, path: appPath, message: '应用程序已启动' }; } } catch (error) { return { success: false, error: error.message }; } }
- src/tools/process.js:12-24 (schema)The input schema definition for the launch_application tool, specifying required 'path' and optional 'args' array and 'wait' boolean.{ name: 'launch_application', description: '启动应用程序', inputSchema: { type: 'object', properties: { path: { type: 'string', description: '应用程序路径或命令' }, args: { type: 'array', items: { type: 'string' }, description: '命令行参数(可选)' }, wait: { type: 'boolean', description: '是否等待程序结束(可选)' }, }, required: ['path'], }, },
- src/tools/process.js:66-79 (registration)The tool dispatcher (executeTool method) that registers and routes 'launch_application' calls to the specific launchApplication handler.async executeTool(name, args) { switch (name) { case 'launch_application': return await this.launchApplication(args.path, args.args, args.wait); case 'kill_process': return await this.killProcess(args.name, args.force); case 'list_processes': return await this.listProcesses(args.filter); case 'get_process_info': return await this.getProcessInfo(args.name); default: throw new Error(`未知工具: ${name}`); } }
- src/tools/process.js:61-64 (registration)The canHandle method registers 'launch_application' by including it in the list of supported tools for capability checking.canHandle(toolName) { const tools = ['launch_application', 'kill_process', 'list_processes', 'get_process_info']; return tools.includes(toolName); }