Created
April 22, 2026 15:06
-
-
Save vtanathip/6f3f3d6215c81f4d0fb792413cd26b51 to your computer and use it in GitHub Desktop.
Script for open Tradingview
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| REM Launch TradingView Desktop on Windows with Chrome DevTools Protocol enabled | |
| REM Usage: scripts\launch_tv_debug.bat [port] | |
| set PORT=%1 | |
| if "%PORT%"=="" set PORT=9222 | |
| REM Kill existing TradingView instances | |
| taskkill /F /IM TradingView.exe >nul 2>&1 | |
| timeout /t 2 /nobreak >nul | |
| REM Auto-detect TradingView install location | |
| set "TV_EXE=" | |
| REM Check common install locations | |
| if exist "%LOCALAPPDATA%\TradingView\TradingView.exe" set "TV_EXE=%LOCALAPPDATA%\TradingView\TradingView.exe" | |
| if exist "%PROGRAMFILES%\TradingView\TradingView.exe" set "TV_EXE=%PROGRAMFILES%\TradingView\TradingView.exe" | |
| if exist "%PROGRAMFILES(x86)%\TradingView\TradingView.exe" set "TV_EXE=%PROGRAMFILES(x86)%\TradingView\TradingView.exe" | |
| REM Check MSIX / Windows Store installs via PowerShell (dir won't work on protected WindowsApps) | |
| if "%TV_EXE%"=="" ( | |
| for /f "usebackq tokens=*" %%i in (`powershell -NoProfile -Command "Get-AppxPackage -Name '*TradingView*' | ForEach-Object { Join-Path $_.InstallLocation 'TradingView.exe' } | Where-Object { Test-Path $_ } | Select-Object -First 1"`) do set "TV_EXE=%%i" | |
| ) | |
| if "%TV_EXE%"=="" ( | |
| for /f "tokens=*" %%i in ('where TradingView.exe 2^>nul') do set "TV_EXE=%%i" | |
| ) | |
| if "%TV_EXE%"=="" ( | |
| echo Error: TradingView not found. | |
| echo Checked: %%LOCALAPPDATA%%\TradingView, %%PROGRAMFILES%%\TradingView, WindowsApps | |
| echo. | |
| echo If installed elsewhere, run manually: | |
| echo "C:\path\to\TradingView.exe" --remote-debugging-port=%PORT% | |
| exit /b 1 | |
| ) | |
| echo Found TradingView at: %TV_EXE% | |
| echo Starting with --remote-debugging-port=%PORT%... | |
| start "" "%TV_EXE%" --remote-debugging-port=%PORT% | |
| echo Waiting for CDP to become available... | |
| timeout /t 5 /nobreak >nul | |
| :check | |
| curl -s http://localhost:%PORT%/json/version >nul 2>&1 | |
| if %errorlevel% neq 0 ( | |
| echo Still waiting... | |
| timeout /t 2 /nobreak >nul | |
| goto check | |
| ) | |
| echo. | |
| echo CDP ready at http://localhost:%PORT% | |
| curl -s http://localhost:%PORT%/json/version | |
| echo. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment