Skip to content

Instantly share code, notes, and snippets.

@louis030195
Created October 14, 2025 17:11
Show Gist options
  • Save louis030195/2f9010209efb078a0f82bdfb0321890a to your computer and use it in GitHub Desktop.
Save louis030195/2f9010209efb078a0f82bdfb0321890a to your computer and use it in GitHub Desktop.
Chrome Installation Workflow for Terminator MCP
name: Install Google Chrome on Windows VM
description: Automated workflow to download and install Google Chrome browser on Windows VM using direct download
version: 2.0.0
date_created: 2025-10-14
author: Claude Code with terminator-mcp-agent
tool_name: execute_sequence
arguments:
steps:
# Step 1: Check if Chrome is already installed
- tool_name: run_command
id: check_chrome
arguments:
engine: javascript
run: |
const fs = require('fs');
console.log('🔍 Checking for existing Chrome installation...');
const chromePaths = [
'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',
'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe',
process.env.LOCALAPPDATA + '\\Google\\Chrome\\Application\\chrome.exe'
];
for (const path of chromePaths) {
if (fs.existsSync(path)) {
console.log('✅ Chrome already installed at: ' + path);
try {
const { execSync } = require('child_process');
const versionCmd = `powershell -Command "(Get-Item '${path}').VersionInfo.FileVersion"`;
const version = execSync(versionCmd, {encoding: 'utf8'}).trim();
console.log('📦 Version: ' + version);
return {
already_installed: true,
installation_path: path,
version: version,
skip_install: 'true'
};
} catch (e) {
return {
already_installed: true,
installation_path: path,
skip_install: 'true'
};
}
}
}
console.log('❌ Chrome not found, will proceed with installation');
return {
already_installed: false,
skip_install: 'false'
};
# Step 2: Download Chrome installer via PowerShell
- tool_name: run_command
id: download_chrome
if: 'skip_install == "false"'
arguments:
engine: javascript
run: |
const { execSync } = require('child_process');
const fs = require('fs');
console.log('📥 Downloading Chrome installer...');
const downloadsPath = process.env.USERPROFILE + '\\Downloads';
const installerPath = downloadsPath + '\\ChromeSetup.exe';
// Remove old installer if exists
if (fs.existsSync(installerPath)) {
console.log('🗑️ Removing old installer...');
fs.unlinkSync(installerPath);
}
try {
// Download using PowerShell
const downloadCmd = `powershell -Command "` +
`$ProgressPreference = 'SilentlyContinue'; ` +
`Invoke-WebRequest -Uri 'https://dl.google.com/chrome/install/latest/chrome_installer.exe' ` +
`-OutFile '${installerPath}' -UseBasicParsing"`;
console.log('⏳ Downloading from Google servers...');
execSync(downloadCmd, { stdio: 'inherit' });
// Verify download
if (fs.existsSync(installerPath)) {
const stats = fs.statSync(installerPath);
console.log('✅ Download complete!');
console.log('📦 Installer size: ' + Math.round(stats.size / 1024 / 1024 * 100) / 100 + ' MB');
console.log('📂 Location: ' + installerPath);
return {
success: true,
installer_path: installerPath,
size_bytes: stats.size
};
} else {
throw new Error('Installer file not found after download');
}
} catch (error) {
console.error('❌ Download failed: ' + error.message);
return {
success: false,
error: error.message
};
}
# Step 3: Run the Chrome installer
- tool_name: run_command
id: install_chrome
if: 'skip_install == "false"'
arguments:
engine: javascript
run: |
const { execSync, spawn } = require('child_process');
const fs = require('fs');
const installerPath = (typeof download_chrome_result !== 'undefined' &&
download_chrome_result.installer_path) ||
process.env.USERPROFILE + '\\Downloads\\ChromeSetup.exe';
if (!fs.existsSync(installerPath)) {
console.log('❌ Installer not found at: ' + installerPath);
return {
success: false,
error: 'Installer not found'
};
}
console.log('🚀 Running Chrome installer...');
console.log('📂 Installer: ' + installerPath);
console.log('⏳ This may take 1-2 minutes...');
try {
// Run installer with silent flags
// Chrome installer doesn't block, so we need to wait manually
execSync(`"${installerPath}" /silent /install`, {
stdio: 'inherit',
windowsHide: true
});
console.log('⏳ Waiting for installation to complete...');
// Wait up to 120 seconds for Chrome to be installed
let installed = false;
const chromePaths = [
'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',
'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe',
process.env.LOCALAPPDATA + '\\Google\\Chrome\\Application\\chrome.exe'
];
for (let i = 0; i < 24; i++) {
await sleep(5000); // Wait 5 seconds
for (const chromePath of chromePaths) {
if (fs.existsSync(chromePath)) {
console.log('✅ Chrome installation detected at: ' + chromePath);
installed = true;
break;
}
}
if (installed) break;
if ((i + 1) % 4 === 0) {
console.log(`⏳ Still waiting... (${(i + 1) * 5}s elapsed)`);
}
}
if (!installed) {
console.log('⚠️ Installation may still be in progress');
console.log('⏳ Waiting additional 30 seconds...');
await sleep(30000);
}
return {
success: true,
installer_path: installerPath
};
} catch (error) {
console.error('⚠️ Installation process error: ' + error.message);
console.log('⏳ Waiting for background installation...');
await sleep(60000);
return {
success: true,
note: 'Installation started, may complete in background'
};
}
# Step 4: Verify Chrome installation
- tool_name: run_command
id: verify_chrome
arguments:
engine: javascript
run: |
const fs = require('fs');
const { execSync } = require('child_process');
console.log('🔍 Verifying Chrome installation...');
const chromePaths = [
'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',
'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe',
process.env.LOCALAPPDATA + '\\Google\\Chrome\\Application\\chrome.exe'
];
for (const path of chromePaths) {
if (fs.existsSync(path)) {
console.log('✅ Chrome successfully installed!');
console.log('📂 Location: ' + path);
try {
const versionCmd = `powershell -Command "(Get-Item '${path}').VersionInfo.FileVersion"`;
const version = execSync(versionCmd, {encoding: 'utf8'}).trim();
console.log('📦 Version: ' + version);
return {
success: true,
installed: true,
installation_path: path,
version: version || 'Unknown'
};
} catch (e) {
return {
success: true,
installed: true,
installation_path: path,
version: 'Unknown'
};
}
}
}
console.log('❌ Chrome installation verification failed');
console.log('Chrome executable not found in expected locations');
return {
success: false,
installed: false,
error: 'Chrome not found after installation'
};
# Step 5: Cleanup installer
- tool_name: run_command
id: cleanup
if: 'skip_install == "false"'
arguments:
engine: javascript
run: |
const fs = require('fs');
console.log('🧹 Cleaning up installer...');
const installerPath = process.env.USERPROFILE + '\\Downloads\\ChromeSetup.exe';
try {
if (fs.existsSync(installerPath)) {
fs.unlinkSync(installerPath);
console.log('✅ Installer removed');
return { cleaned: true };
} else {
console.log('ℹ️ No installer to clean up');
return { cleaned: false };
}
} catch (error) {
console.log('⚠️ Could not remove installer: ' + error.message);
return { cleaned: false, error: error.message };
}
stop_on_error: false
output: |
const installed = (typeof verify_chrome_result !== 'undefined' && verify_chrome_result.installed) || false;
const path = (typeof verify_chrome_result !== 'undefined' && verify_chrome_result.installation_path) || 'Not found';
const version = (typeof verify_chrome_result !== 'undefined' && verify_chrome_result.version) || 'Unknown';
const wasAlreadyInstalled = (typeof check_chrome_result !== 'undefined' && check_chrome_result.already_installed) || false;
console.log('\n╔════════════════════════════════════════╗');
console.log('║ Chrome Installation Complete ║');
console.log('╚════════════════════════════════════════╝\n');
if (wasAlreadyInstalled) {
console.log('ℹ️ Chrome was already installed');
} else if (installed) {
console.log('✅ Chrome installed successfully!');
} else {
console.log('❌ Chrome installation failed');
}
console.log('📂 Path: ' + path);
console.log('📦 Version: ' + version);
console.log('');
return {
success: installed,
installed: installed,
already_installed: wasAlreadyInstalled,
installation_path: path,
version: version
};
metadata:
requirements:
- Windows VM with MCP server running
- Internet connection
- Node.js installed (for JavaScript engine)
tested_on:
- Windows Server 2022
- Windows 10/11
- MCP server version 0.17.6+
notes:
- Uses direct PowerShell download (more reliable than browser automation)
- Chrome installer runs with /silent /install flags
- Installation typically takes 60-120 seconds
- Automatically cleans up installer after completion
troubleshooting:
- If download fails, check internet connectivity and firewall
- Chrome downloads from dl.google.com
- Installer may take longer on slower systems
- Check if antivirus is blocking the installer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment