45 lines
1.8 KiB
Batchfile
45 lines
1.8 KiB
Batchfile
@echo off
|
|
setlocal EnableExtensions
|
|
set "PATH=%SystemRoot%\System32;%PATH%"
|
|
cd /d "%~dp0"
|
|
set "COLLECTOR_GUI=1"
|
|
|
|
if exist "%SystemRoot%\System32\chcp.com" (
|
|
"%SystemRoot%\System32\chcp.com" 65001 >nul 2>&1
|
|
)
|
|
|
|
if not exist ".venv\Scripts\pythonw.exe" (
|
|
call "%~dp0setup.bat" silent
|
|
if not exist ".venv\Scripts\pythonw.exe" (
|
|
powershell -NoProfile -Command "Add-Type -AssemblyName PresentationFramework;[System.Windows.MessageBox]::Show('安装失败,请先安装 Python 3.10+ 并勾选 Add to PATH','抖音采集器','OK','Error')" >nul 2>&1
|
|
exit /b 1
|
|
)
|
|
)
|
|
|
|
if not exist "%~dp0.first_run_done" (
|
|
set "DESKTOP=%USERPROFILE%\Desktop"
|
|
set "LNK=%DESKTOP%\DouyinIMCollector.lnk"
|
|
if not exist "%LNK%" (
|
|
powershell -NoProfile -ExecutionPolicy Bypass -Command "$s=(New-Object -ComObject WScript.Shell).CreateShortcut('%LNK%');$s.TargetPath='%~dp0run_collector.vbs';$s.WorkingDirectory='%~dp0';$s.Description='Douyin IM Collector';$s.Save()" >nul 2>&1
|
|
)
|
|
echo ok> "%~dp0.first_run_done"
|
|
)
|
|
|
|
set "PYW=.venv\Scripts\pythonw.exe"
|
|
set "PLAYWRIGHT_BROWSERS_PATH=%~dp0playwright-browsers"
|
|
if not exist "%PLAYWRIGHT_BROWSERS_PATH%" mkdir "%PLAYWRIGHT_BROWSERS_PATH%"
|
|
|
|
powershell -NoProfile -ExecutionPolicy Bypass -Command "8765..8770|ForEach-Object{Get-NetTCPConnection -LocalPort $_ -State Listen -ErrorAction SilentlyContinue|ForEach-Object{Stop-Process -Id $_.OwningProcess -Force -ErrorAction SilentlyContinue}}" >nul 2>&1
|
|
|
|
set "HAS_CHROME=0"
|
|
for /d %%D in ("%PLAYWRIGHT_BROWSERS_PATH%\chromium-*") do (
|
|
if exist "%%D\chrome-win64\chrome.exe" set "HAS_CHROME=1"
|
|
if exist "%%D\chrome-win\chrome.exe" set "HAS_CHROME=1"
|
|
)
|
|
if "%HAS_CHROME%"=="0" (
|
|
".venv\Scripts\python.exe" -m playwright install chromium >nul 2>&1
|
|
)
|
|
|
|
start "" "%PYW%" "%~dp0run_douyin_collector.py"
|
|
endlocal
|