Files
quizify/start.bat
SimolZimol 447402ab75 new file: .gitignore
new file:   Dockerfile
	new file:   app.py
	new file:   requirements.txt
	new file:   start.bat
	new file:   templates/login.html
	new file:   templates/playlists.html
	new file:   templates/quiz.html
2025-05-15 21:58:50 +02:00

76 lines
1.9 KiB
Batchfile

@echo off
:: Save the current directory
set CURRENT_DIR=%cd%
:: Check for administrator rights
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
if '%errorlevel%' NEQ '0' (
echo Requesting administrator rights...
goto UACPrompt
) else ( goto AdminRights )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "cmd.exe", "/c cd /d %CURRENT_DIR% && %~s0 %*", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B
:AdminRights
echo Administrator rights confirmed.
:: Change to the directory where the script is located
cd /d %CURRENT_DIR%
REM Set the directory for the virtual environment
set VENV_DIR=ven
REM Check if the virtual environment directory exists
if not exist %VENV_DIR% (
echo Virtual environment not found. Creating virtual environment...
python -m venv %VENV_DIR%
if %errorlevel% neq 0 (
echo Error: Failed to create virtual environment.
pause
exit /B %errorlevel%
)
)
REM Activate the virtual environment
call %VENV_DIR%\Scripts\activate
if %errorlevel% neq 0 (
echo Error: Failed to activate virtual environment.
pause
exit /B %errorlevel%
)
REM Check and install required packages
echo Installing required packages from requirements.txt...
pip install -r requirements.txt
if %errorlevel% neq 0 (
echo Error: Failed to install required packages.
pause
exit /B %errorlevel%
)
REM Start the bot
echo Starting the bot...
python app.py
if %errorlevel% neq 0 (
echo Error: Failed to start the bot.
pause
exit /B %errorlevel%
)
REM Deactivate the virtual environment after the bot stops
deactivate
if %errorlevel% neq 0 (
echo Error: Failed to deactivate virtual environment.
pause
exit /B %errorlevel%
)
echo Bot stopped. Press any key to close the window.
pause