$ErrorActionPreference = 'Continue'
$chrome = "C:\Program Files\Google\Chrome\Application\chrome.exe"
$argList = "--remote-debugging-port=9223 --user-data-dir=C:\ChromeDebug_BJH --no-first-run --no-default-browser-check --disable-crash-reporter --noerrdialogs https://baijiahao.baidu.com"

Write-Host "Starting Chrome..."
$proc = Start-Process $chrome -ArgumentList $argList -PassThru
Write-Host "PID: $($proc.Id)"

Start-Sleep 5

$running = Get-Process -Id $proc.Id -ErrorAction SilentlyContinue
if ($running) {
    Write-Host "SUCCESS - Chrome is running. Window: $($running.MainWindowTitle)"
} else {
    Write-Host "Chrome exited immediately with code: $($proc.ExitCode)"
}
