Files
inquiry_robot/deploy/_remote_wmi_start.ps1
T

18 lines
971 B
PowerShell

Write-Output "=== watchdog hint ==="
Select-String -Path "C:\yutongda\ops\watchdog.ps1" -Pattern "8910|kill|Stop-Process|8810" -ErrorAction SilentlyContinue | Select-Object -First 30 Line
Write-Output "=== start via WMI ==="
$wrapper = "C:\ytd-test\ops\run-agent-http.cmd"
Get-NetTCPConnection -LocalPort 8910 -ErrorAction SilentlyContinue |
Select-Object -ExpandProperty OwningProcess -Unique |
ForEach-Object { Stop-Process -Id $_ -Force -ErrorAction SilentlyContinue }
Start-Sleep -Seconds 1
$r = ([wmiclass]"Win32_Process").Create("cmd.exe /c `"$wrapper`"")
Write-Output "WMI ReturnValue=$($r.ReturnValue) PID=$($r.ProcessId)"
Start-Sleep -Seconds 8
cmd /c "curl.exe -s http://127.0.0.1:8910/health"
Write-Output ""
netstat -ano | findstr ":8910"
Get-CimInstance Win32_Process -Filter "Name='cmd.exe' OR Name='python.exe'" |
Where-Object { $_.CommandLine -match "ytd-test|agent.http_app|run-agent" } |
Select-Object ProcessId, Name, CommandLine | Format-List