Skip to content

Instantly share code, notes, and snippets.

@Geczy
Created December 27, 2024 11:57
Show Gist options
  • Save Geczy/0e9b4fe930639aa7e71a7a195a547f7d to your computer and use it in GitHub Desktop.
Save Geczy/0e9b4fe930639aa7e71a7a195a547f7d to your computer and use it in GitHub Desktop.

Here’s a fancier and user-friendly version of the batch script with clear customer-facing language, debug info for reporting, and improved symbols for feedback. It will make the experience more polished and easier to understand for the customer.

Save as run_debug_with_bun.bat

@echo off REM ========================== REM Fancy Debug Automation Script REM ==========================

REM Set constants set OBS_PORT=1234 set SCRIPT_PATH=saveConsoleAndHAR.js set DEBUG_LOG=debug_info.log

REM Clear any previous debug logs if exist %DEBUG_LOG% del %DEBUG_LOG%

echo ============================================================ echo 🌟 Welcome to the OBS Debug Automation Script 🌟 echo ============================================================ echo This script will: echo 1️⃣ Start OBS Studio with remote debugging. echo 2️⃣ Ensure Bun and Puppeteer are installed. echo 3️⃣ Run the debug script to collect console logs and HAR data. echo ============================================================ echo.

REM -------------------------------------------------------------- REM Step 1: Locate OBS Path from Registry REM -------------------------------------------------------------- echo βš™οΈ Step 1: Locating OBS Studio... for /f "tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" /s /f "OBS Studio" ^| findstr "InstallLocation"') do ( set OBS_PATH=%%b )

if "%OBS_PATH%"=="" ( echo πŸ›‘ ERROR: OBS Studio not found in the Windows Registry. >> %DEBUG_LOG% echo Possible Issues: echo - OBS Studio is not installed. echo - OBS Studio installation was not added to the Registry. echo πŸ’‘ Solution: Please reinstall OBS Studio. echo Debug Info: See %DEBUG_LOG% for details. pause exit /b )

set OBS_EXEC="%OBS_PATH%\bin\64bit\obs64.exe" if not exist %OBS_EXEC% ( echo πŸ›‘ ERROR: OBS executable not found at %OBS_EXEC%. >> %DEBUG_LOG% echo Possible Issues: echo - OBS Studio installation might be incomplete. echo πŸ’‘ Solution: Verify the OBS installation path. echo Debug Info: See %DEBUG_LOG% for details. pause exit /b )

echo βœ… OBS Studio found at: %OBS_EXEC% echo.

REM -------------------------------------------------------------- REM Step 2: Start OBS with Remote Debugging REM -------------------------------------------------------------- echo βš™οΈ Step 2: Starting OBS Studio with remote debugging on port %OBS_PORT%... start "" %OBS_EXEC% --remote-debugging-port=%OBS_PORT% if %ERRORLEVEL% neq 0 ( echo πŸ›‘ ERROR: Failed to start OBS Studio. >> %DEBUG_LOG% echo πŸ’‘ Solution: Ensure OBS Studio is properly installed and accessible. echo Debug Info: See %DEBUG_LOG% for details. pause exit /b ) echo βœ… OBS Studio started successfully. echo.

REM -------------------------------------------------------------- REM Step 3: Check and Install Bun REM -------------------------------------------------------------- echo βš™οΈ Step 3: Checking for Bun... bun --version >nul 2>&1 if %ERRORLEVEL% neq 0 ( echo ⚠️ Bun is not installed. Installing Bun now... powershell -Command "irm bun.sh/install.ps1 | iex" >> %DEBUG_LOG% 2>&1 if %ERRORLEVEL% neq 0 ( echo πŸ›‘ ERROR: Failed to install Bun. >> %DEBUG_LOG% echo πŸ’‘ Solution: Install Bun manually from https://bun.sh. echo Debug Info: See %DEBUG_LOG% for details. pause exit /b ) echo βœ… Bun installed successfully. ) else ( echo βœ… Bun is already installed. ) echo.

REM -------------------------------------------------------------- REM Step 4: Check and Install Puppeteer REM -------------------------------------------------------------- echo βš™οΈ Step 4: Checking for Puppeteer... bun pm ls puppeteer >nul 2>&1 if %ERRORLEVEL% neq 0 ( echo ⚠️ Puppeteer is not installed. Installing Puppeteer now... bun add puppeteer >> %DEBUG_LOG% 2>&1 if %ERRORLEVEL% neq 0 ( echo πŸ›‘ ERROR: Failed to install Puppeteer. >> %DEBUG_LOG% echo πŸ’‘ Solution: Check your Bun installation and try again. echo Debug Info: See %DEBUG_LOG% for details. pause exit /b ) echo βœ… Puppeteer installed successfully. ) else ( echo βœ… Puppeteer is already installed. ) echo.

REM -------------------------------------------------------------- REM Step 5: Run the Puppeteer Script REM -------------------------------------------------------------- echo βš™οΈ Step 5: Running Puppeteer script to collect logs and HAR data... bun run %SCRIPT_PATH% >> %DEBUG_LOG% 2>&1 if %ERRORLEVEL% neq 0 ( echo πŸ›‘ ERROR: Puppeteer script execution failed. >> %DEBUG_LOG% echo Possible Issues: echo - Script syntax issues. echo - Puppeteer-related errors. echo πŸ’‘ Solution: Verify the script and dependencies. echo Debug Info: See %DEBUG_LOG% for details. pause exit /b ) echo βœ… Debugging complete! Logs and HAR data have been saved. echo.

REM -------------------------------------------------------------- REM Completion REM -------------------------------------------------------------- echo πŸŽ‰ All tasks completed successfully! πŸŽ‰ echo You can find the collected data in the output files. echo If you encounter any issues, please share %DEBUG_LOG% with your support team. pause

Key Features of the Script: 1. Fancy Design: β€’ Uses symbols (βœ…, πŸ›‘, ⚠️, πŸŽ‰, βš™οΈ) for clear and visually appealing feedback. β€’ Provides step-by-step information for the customer. 2. Customer-Friendly Language: β€’ Clear language with explanations for issues and solutions. β€’ Debugging steps included for easier problem identification. 3. Debug Logging: β€’ Saves detailed debug information to debug_info.log for reporting. β€’ Includes all critical errors and installation outputs in the log. 4. Automatic Handling: β€’ Dynamically resolves OBS installation path from the Windows Registry. β€’ Installs Bun and Puppeteer if not already available. 5. Clear Next Steps: β€’ Offers solutions and directs the user to the appropriate resources when errors occur. β€’ Ensures the customer can act on any issues without confusion.

Output Example:

============================================================ 🌟 Welcome to the OBS Debug Automation Script 🌟

This script will: 1️⃣ Start OBS Studio with remote debugging. 2️⃣ Ensure Bun and Puppeteer are installed. 3️⃣ Run the debug script to collect console logs and HAR data.

βš™οΈ Step 1: Locating OBS Studio... βœ… OBS Studio found at: "C:\Program Files\obs-studio\bin\64bit\obs64.exe"

βš™οΈ Step 2: Starting OBS Studio with remote debugging on port 1234... βœ… OBS Studio started successfully.

βš™οΈ Step 3: Checking for Bun... βœ… Bun is already installed.

βš™οΈ Step 4: Checking for Puppeteer... βœ… Puppeteer is already installed.

βš™οΈ Step 5: Running Puppeteer script to collect logs and HAR data... βœ… Debugging complete! Logs and HAR data have been saved.

πŸŽ‰ All tasks completed successfully! πŸŽ‰ You can find the collected data in the output files. If you encounter any issues, please share debug_info.log with your support team.

How It Helps: β€’ Customers get clear, actionable messages at every step. β€’ Debug logs can be shared with you for efficient troubleshooting. β€’ Handles common issues gracefully with easy-to-understand solutions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment