11@ echo off
2- REM Set console code page to UTF-8 to handle non-ASCII characters in paths or script output
2+ REM Set the console code page to UTF-8 to prevent issues with non-ASCII characters in paths or output.
33chcp 65001 > nul
44
5- REM Change directory to the location of this batch file
6- REM This ensures that the script can find any relative files correctly
5+ REM Change the current directory to the location of this batch file.
6+ REM This ensures that the script can correctly find any relative files (e.g., config files, other scripts).
77cd /d " %~dp0 "
88
9- REM Launch the Python GUI script without a console window
10- REM "start" with an empty title "" runs the command in a new process and allows the batch file to exit immediately
11- REM "pyw.exe" is used to run Python scripts without opening a console window, suitable for GUI applications
12- start " " pyw insta360convert.py
9+ REM --- Auto-detect and execute Python environment ---
10+
11+ REM Priority 1: Try the Python Launcher (py.exe).
12+ REM This is the standard way to run Python on Windows when installed from python.org,
13+ REM and it works even if Python is not in the system's PATH.
14+ where py > nul 2 > nul
15+ if %errorlevel% == 0 (
16+ echo Launching with Python Launcher (py.exe)...
17+ py -w insta360convert.py
18+ exit /b
19+ )
20+
21+ REM Priority 2: Try python.exe.
22+ REM This covers installations from the Windows Store or official installers where python.exe was added to the PATH.
23+ REM The "start /b" command runs the script without creating a new console window.
24+ where python > nul 2 > nul
25+ if %errorlevel% == 0 (
26+ echo Launching with python.exe...
27+ start /b python insta360convert.py
28+ exit /b
29+ )
30+
31+ REM Priority 3: Fallback to pyw.exe directly.
32+ REM This handles rare cases where only pyw.exe is in the PATH.
33+ REM The "start """ runs the command in a new process, allowing the batch file to exit immediately.
34+ where pyw > nul 2 > nul
35+ if %errorlevel% == 0 (
36+ echo Launching with pyw.exe...
37+ start " " pyw insta360convert.py
38+ exit /b
39+ )
40+
41+ REM --- Error handling if no Python executable was found ---
42+ echo .
43+ echo =================================================================
44+ echo Error: Could not find a Python installation.
45+ echo .
46+ echo This program requires Python to run.
47+ echo Please install it from the Microsoft Store or python.org.
48+ echo =================================================================
49+ echo .
50+ pause
0 commit comments