mcp-windows-screenshots
Version:
MCP server for accessing Windows screenshots from WSL2
79 lines (69 loc) • 2.96 kB
JavaScript
// Test script specifically for Windows environments
import { spawnSync } from 'child_process';
import { existsSync, readdirSync } from 'fs';
import os from 'os';
import path from 'path';
console.log('=== Windows Path Testing ===\n');
console.log('Platform:', process.platform);
console.log('Username:', os.userInfo().username);
// Test registry query on Windows
if (process.platform === 'win32') {
console.log('\n=== Testing Registry Query ===');
const result = spawnSync('reg', [
'query',
'HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders',
'/v', '{B7BEDE81-DF94-4682-A7D8-57A52620B86F}'
], {
encoding: 'utf8',
shell: true
});
if (result.status === 0) {
console.log('Registry query successful!');
const lines = result.stdout.split('\n');
for (const line of lines) {
if (line.includes('{B7BEDE81-DF94-4682-A7D8-57A52620B86F}')) {
const parts = line.split('REG_EXPAND_SZ');
if (parts.length > 1) {
let screenshotPath = parts[1].trim();
console.log('Found Screenshots path:', screenshotPath);
// Expand environment variables
screenshotPath = screenshotPath.replace('%USERPROFILE%', process.env.USERPROFILE || `C:\\Users\\${os.userInfo().username}`);
console.log('Expanded path:', screenshotPath);
// Check if path exists
if (existsSync(screenshotPath)) {
console.log('✅ Path exists!');
// List files in the directory
try {
const files = readdirSync(screenshotPath);
const screenshots = files.filter(f => /\.(png|jpg|jpeg|bmp|gif)$/i.test(f));
console.log(`Found ${screenshots.length} screenshot files:`);
screenshots.slice(0, 5).forEach(f => console.log(` - ${f}`));
if (screenshots.length > 5) console.log(` ... and ${screenshots.length - 5} more`);
} catch (e) {
console.log('Could not list files:', e.message);
}
} else {
console.log('❌ Path does not exist');
}
}
}
}
} else {
console.log('Registry query failed:', result.stderr);
}
// Test common Windows paths
console.log('\n=== Testing Common Windows Paths ===');
const commonPaths = [
`C:\\Users\\${os.userInfo().username}\\Pictures\\Screenshots`,
`C:\\Users\\${os.userInfo().username}\\Pictures`,
`C:\\Users\\${os.userInfo().username}\\OneDrive\\Pictures\\Screenshots`,
`C:\\Users\\${os.userInfo().username}\\Desktop`,
`C:\\Users\\${os.userInfo().username}\\Documents\\Screenshots`
];
for (const testPath of commonPaths) {
console.log(`${testPath}: ${existsSync(testPath) ? '✅ Exists' : '❌ Not found'}`);
}
} else {
console.log('This script is designed for Windows. Run test-detection.mjs for WSL/Linux testing.');
}