| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- @echo off
- REM Digital Human Chrome Kiosk Mode Startup Script (Silent Background Mode)
- REM Function: Auto start frontend and backend services silently, then open Chrome in kiosk mode with hidden taskbar
- REM Run silently using VBScript wrapper
- if not "%1"=="hidden" (
- REM Create a temporary VBScript to run this batch file silently
- echo Set WshShell = CreateObject("WScript.Shell"^) > "%TEMP%\run_silent.vbs"
- echo WshShell.Run """%~f0"" hidden", 0, False >> "%TEMP%\run_silent.vbs"
- cscript //nologo "%TEMP%\run_silent.vbs"
- del "%TEMP%\run_silent.vbs"
- exit /b
- )
- REM Keep window open (but hidden)
- setlocal enabledelayedexpansion
- REM Use GBK encoding for Chinese characters (Windows default)
- chcp 936 >nul 2>&1
- REM Configuration
- set FRONTEND_URL=http://localhost:3000/sentio
- set BACKEND_URL=http://localhost:8000
- set WAIT_TIME=10
- set CHECK_INTERVAL=2
- REM Get script directory and project root (parent directory)
- set "SCRIPT_DIR=%~dp0"
- set "PROJECT_ROOT=%SCRIPT_DIR%.."
- REM Remove trailing backslash if present
- if "%PROJECT_ROOT:~-1%"=="\" set "PROJECT_ROOT=%PROJECT_ROOT:~0,-1%"
- set "WEB_DIR=%PROJECT_ROOT%\web"
- REM Find Chrome browser path
- set "CHROME_PATH="
- REM Check Qoom Chrome (user specified path) - try different possible exe names
- if exist "C:\Program Files\Qoom Chrome\chrome.exe" (
- set "CHROME_PATH=C:\Program Files\Qoom Chrome\chrome.exe"
- goto found_chrome
- )
- if exist "C:\Program Files\Qoom Chrome\QoomChrome.exe" (
- set "CHROME_PATH=C:\Program Files\Qoom Chrome\QoomChrome.exe"
- goto found_chrome
- )
- if exist "C:\Program Files\Qoom Chrome\Qoom Chrome.exe" (
- set "CHROME_PATH=C:\Program Files\Qoom Chrome\Qoom Chrome.exe"
- goto found_chrome
- )
- if exist "C:\Program Files\Qoom Chrome\Application\chrome.exe" (
- set "CHROME_PATH=C:\Program Files\Qoom Chrome\Application\chrome.exe"
- goto found_chrome
- )
- REM Check common Google Chrome installation paths
- if exist "%ProgramFiles%\Google\Chrome\Application\chrome.exe" (
- set "CHROME_PATH=%ProgramFiles%\Google\Chrome\Application\chrome.exe"
- goto found_chrome
- )
- if exist "%ProgramFiles(x86)%\Google\Chrome\Application\chrome.exe" (
- set "CHROME_PATH=%ProgramFiles(x86)%\Google\Chrome\Application\chrome.exe"
- goto found_chrome
- )
- if exist "%LOCALAPPDATA%\Google\Chrome\Application\chrome.exe" (
- set "CHROME_PATH=%LOCALAPPDATA%\Google\Chrome\Application\chrome.exe"
- goto found_chrome
- )
- REM Try to find from registry
- for /f "tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe" /ve 2^>nul ^| findstr /i "REG_SZ"') do (
- set "CHROME_PATH=%%b"
- if exist "!CHROME_PATH!" (
- goto found_chrome
- )
- )
- REM Try to find from user registry
- for /f "tokens=2*" %%a in ('reg query "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe" /ve 2^>nul ^| findstr /i "REG_SZ"') do (
- set "CHROME_PATH=%%b"
- if exist "!CHROME_PATH!" (
- goto found_chrome
- )
- )
- REM If still not found, exit silently (log to file for debugging)
- echo Chrome not found at %date% %time% >> "%TEMP%\digital_human_error.log"
- exit /b 1
- :found_chrome
- REM Check web directory
- if not exist "%WEB_DIR%" (
- echo Web directory not found at %date% %time% >> "%TEMP%\digital_human_error.log"
- exit /b 1
- )
- REM Check Node.js
- where node >nul 2>&1
- if errorlevel 1 (
- echo Node.js not found at %date% %time% >> "%TEMP%\digital_human_error.log"
- exit /b 1
- )
- REM Check Python
- where python >nul 2>&1
- if errorlevel 1 (
- echo Python not found at %date% %time% >> "%TEMP%\digital_human_error.log"
- exit /b 1
- )
- REM Prevent system sleep/hibernate
- REM Disable sleep/hibernate timeouts
- powercfg /change standby-timeout-ac 0 >nul 2>&1
- powercfg /change standby-timeout-dc 0 >nul 2>&1
- powercfg /change hibernate-timeout-ac 0 >nul 2>&1
- powercfg /change hibernate-timeout-dc 0 >nul 2>&1
- REM Keep display on (set to 0 = never turn off)
- powercfg /change monitor-timeout-ac 0 >nul 2>&1
- powercfg /change monitor-timeout-dc 0 >nul 2>&1
- REM Use SetThreadExecutionState API to prevent sleep (more reliable)
- if exist "%~dp0prevent-sleep.ps1" (
- powershell -ExecutionPolicy Bypass -WindowStyle Hidden -File "%~dp0prevent-sleep.ps1" 2>nul
- ) else (
- REM Fallback: inline PowerShell command
- powershell -WindowStyle Hidden -Command "$code = '[DllImport(\"kernel32.dll\")] public static extern uint SetThreadExecutionState(uint esFlags); public const uint ES_CONTINUOUS = 0x80000000; public const uint ES_SYSTEM_REQUIRED = 0x00000001; public const uint ES_DISPLAY_REQUIRED = 0x00000002; public static void PreventSleep() { SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED); }'; Add-Type -MemberDefinition $code -Name Win32 -Namespace System; [System.Win32]::PreventSleep()" 2>nul
- )
- REM Hide taskbar using PowerShell script (if script exists)
- if exist "%~dp0hide-taskbar.ps1" (
- powershell -ExecutionPolicy Bypass -WindowStyle Hidden -File "%~dp0hide-taskbar.ps1" 2>nul
- )
- REM Start frontend service silently (completely hidden)
- powershell -WindowStyle Hidden -Command "Start-Process -FilePath 'cmd.exe' -ArgumentList '/c', 'cd /d %WEB_DIR% && npm run dev' -WindowStyle Hidden" 2>nul
- if errorlevel 1 (
- REM Fallback: use start /min if PowerShell fails
- start /min "" cmd /c "cd /d %WEB_DIR% && npm run dev >nul 2>&1"
- )
- REM Start backend service silently (completely hidden)
- powershell -WindowStyle Hidden -Command "Start-Process -FilePath 'cmd.exe' -ArgumentList '/c', 'cd /d %PROJECT_ROOT% && python main.py' -WindowStyle Hidden" 2>nul
- if errorlevel 1 (
- REM Fallback: use start /min if PowerShell fails
- start /min "" cmd /c "cd /d %PROJECT_ROOT% && python main.py >nul 2>&1"
- )
- REM Wait for services to start
- timeout /t %WAIT_TIME% /nobreak >nul
- REM Open Chrome in kiosk mode with fullscreen and hidden taskbar
- REM --kiosk: Fullscreen kiosk mode (hides taskbar automatically)
- REM --start-fullscreen: Start in fullscreen mode
- REM --disable-infobars: Hide info bars
- REM --autoplay-policy: Allow autoplay
- REM Create Chrome user data directory for persistent permissions
- set "CHROME_USER_DATA=%TEMP%\chrome-digital-human"
- if not exist "%CHROME_USER_DATA%" mkdir "%CHROME_USER_DATA%"
- REM Setup Chrome permissions for microphone access (if script exists)
- if exist "%~dp0setup-chrome-permissions.ps1" (
- powershell -ExecutionPolicy Bypass -WindowStyle Hidden -Command "& '%~dp0setup-chrome-permissions.ps1' -ChromeUserData '%CHROME_USER_DATA%' -Origin '%FRONTEND_URL%'" 2>nul
- )
- REM Open Chrome in kiosk mode with microphone auto-permission
- REM Note: Removed --use-fake-ui-for-media-stream and --use-fake-device-for-media-stream to allow real microphone access
- REM --unsafely-treat-insecure-origin-as-secure: Allow localhost to access media devices
- REM --user-data-dir: Use separate user data directory to persist permissions
- start "" "%CHROME_PATH%" --kiosk --start-fullscreen --kiosk-printing --disable-infobars --disable-session-crashed-bubble --disable-restore-session-state --no-first-run --disable-features=TranslateUI --autoplay-policy=no-user-gesture-required --force-device-scale-factor=1 --disable-features=AutoHideScrollbars --force-color-profile=srgb --disable-pinch --overscroll-history-navigation=0 --disable-background-networking --disable-background-timer-throttling --disable-breakpad --disable-client-side-phishing-detection --disable-component-update --disable-default-apps --disable-domain-reliability --disable-features=AudioServiceOutOfProcess --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --disable-translate --metrics-recording-only --no-first-run --safebrowsing-disable-auto-update --disable-blink-features=AutomationControlled --exclude-switches=enable-automation --password-store=basic --use-mock-keychain --user-data-dir="%CHROME_USER_DATA%" --enable-features=UseModernMediaControls --unsafely-treat-insecure-origin-as-secure=%FRONTEND_URL% --allow-running-insecure-content "%FRONTEND_URL%"
- REM Keep script running silently and prevent sleep continuously
- :loop
- REM Refresh sleep prevention every 30 seconds to ensure it stays active
- if exist "%~dp0prevent-sleep.ps1" (
- powershell -ExecutionPolicy Bypass -WindowStyle Hidden -File "%~dp0prevent-sleep.ps1" 2>nul
- ) else (
- powershell -WindowStyle Hidden -Command "$code = '[DllImport(\"kernel32.dll\")] public static extern uint SetThreadExecutionState(uint esFlags); public const uint ES_CONTINUOUS = 0x80000000; public const uint ES_SYSTEM_REQUIRED = 0x00000001; public const uint ES_DISPLAY_REQUIRED = 0x00000002; public static void PreventSleep() { SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED); }'; Add-Type -MemberDefinition $code -Name Win32 -Namespace System; [System.Win32]::PreventSleep()" 2>nul
- )
- timeout /t 30 /nobreak >nul
- goto loop
|