-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathWindows-One-Click-Installer.bat
More file actions
132 lines (109 loc) · 4.45 KB
/
Windows-One-Click-Installer.bat
File metadata and controls
132 lines (109 loc) · 4.45 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
121
122
123
124
125
126
127
128
129
130
131
132
@echo off
setlocal enabledelayedexpansion
:: Check for administrator privileges
NET SESSION >nul 2>&1
if %errorlevel% neq 0 (
echo #######################################################
echo # PLEASE RUN THIS SCRIPT AS ADMINISTRATOR! #
echo # Right-click -> Run as Administrator #
echo #######################################################
timeout /t 5
exit /b 1
)
:: Configuration
set PY_VER=3.13
:: Dynamic path for any username
set PY_DIR_PROGRAMFILES=%ProgramFiles%\Python313
set PY_DIR_APPDATA=%LOCALAPPDATA%\Programs\Python\Python313
set PY_EXE_PROGRAMFILES=%PY_DIR_PROGRAMFILES%\python.exe
set PY_EXE_APPDATA=%PY_DIR_APPDATA%\python.exe
set SCRIPT_URL=https://raw.githubusercontent.com/apple050620312/NCUT-Internet-Auto-Login/refs/heads/main/NCUT_Internet_Auto_Login.py
:: [CHANGED] New installation directory (Clean & Hidden from Startup folder)
set INSTALL_DIR=%ProgramData%\NCUT_AutoLogin
set SCRIPT_PATH=%INSTALL_DIR%\NCUT_Internet_Auto_Login.py
:: Get temp folder path
set TEMP_INSTALLER=%TEMP%\python_installer.exe
:: Step 1: Check for existing Python installations
echo Checking Python %PY_VER% installation...
set PY_EXE=
if exist "%PY_EXE_PROGRAMFILES%" (
set PY_EXE=%PY_EXE_PROGRAMFILES%
set PIP_EXE=%PY_DIR_PROGRAMFILES%\Scripts\pip.exe
echo Found Python %PY_VER% in Program Files.
goto python_installed
)
if exist "%PY_EXE_APPDATA%" (
set PY_EXE=%PY_EXE_APPDATA%
set PIP_EXE=%PY_DIR_APPDATA%\Scripts\pip.exe
echo Found Python %PY_VER% in AppData.
goto python_installed
)
:: Step 2: Install Python if not found
echo Downloading Python %PY_VER% to temp folder...
curl -o "%TEMP_INSTALLER%" https://www.python.org/ftp/python/3.13.0/python-3.13.0-amd64.exe || (
echo Failed to download Python installer
timeout /t 5
exit /b 1
)
echo Installing Python from temp location...
start /wait "" "%TEMP_INSTALLER%" /quiet InstallAllUsers=0 PrependPath=1 TargetDir="%PY_DIR_APPDATA%" || (
echo Failed to run Python installer
del "%TEMP_INSTALLER%" >nul 2>&1
timeout /t 5
exit /b 1
)
:: Clean up installer
del "%TEMP_INSTALLER%" >nul 2>&1
set PY_EXE=%PY_EXE_APPDATA%
set PIP_EXE=%PY_DIR_APPDATA%\Scripts\pip.exe
:: Update PATH
setx PATH "%PATH%;%PY_DIR_APPDATA%;%PY_DIR_APPDATA%\Scripts" >nul 2>&1
:: Verify installation
if not exist "%PY_EXE%" (
echo Failed to install Python %PY_VER%
timeout /t 5
exit /b 1
)
:python_installed
echo Setting Python as default program for .py files...
assoc .py=Python.File >nul 2>&1
ftype Python.File="%PY_EXE%" "%%1" %%* >nul 2>&1
:: Step 3: Install requests package
echo Installing required packages...
"%PY_EXE%" -m pip install requests --quiet
:: Step 4: Create Directory and Download auto-login script
echo Creating installation directory...
if not exist "%INSTALL_DIR%" mkdir "%INSTALL_DIR%"
echo Downloading NCUT login script...
curl -o "%SCRIPT_PATH%" %SCRIPT_URL% || (
echo Failed to download login script
timeout /t 5
exit /b 1
)
:: [CLEANUP] Remove old script from Startup folder if exists (to prevent double run)
if exist "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Startup\NCUT_Internet_Auto_Login.py" (
echo Removing old script from Startup folder to prevent double execution...
del "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Startup\NCUT_Internet_Auto_Login.py"
)
:: Step 5: Create Scheduled Task (Unattended Mode)
echo Creating system startup task...
:: /sc onstart = Runs when Windows boots (before login)
:: /ru SYSTEM = Runs with System privileges
:: /tn "NCUT Auto Login" = Task Name
schtasks /create /tn "NCUT Auto Login" /tr "\"%PY_EXE%\" \"%SCRIPT_PATH%\"" /sc onstart /ru SYSTEM /rl HIGHEST /f >nul 2>&1
:: Step 6: Start the script immediately (so you don't have to reboot now)
echo Starting login service immediately...
start "" "%PY_EXE%" "%SCRIPT_PATH%"
echo #######################################################
echo # INSTALLATION COMPLETED SUCCESSFULLY! #
echo # #
echo # Python Script Location: #
echo # %SCRIPT_PATH%
echo # #
echo # Status: #
echo # - Unattended Mode: ACTIVE (/sc onstart) #
echo # - Runs automatically at BOOT (No login needed) #
echo # - Runs with SYSTEM privileges #
echo #######################################################
timeout /t 5
exit /b 0