-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.bat
More file actions
122 lines (109 loc) · 3.77 KB
/
Copy pathstart.bat
File metadata and controls
122 lines (109 loc) · 3.77 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
@echo off
title LocalShare — WiFi File Sharing
color 0A
setlocal enabledelayedexpansion
echo.
echo ============================================
echo LocalShare ^| Fast WiFi File Sharing
echo ============================================
echo.
:: ── Step 1: Check / install Node.js ───────────────────────────────────────
where node >nul 2>&1
if %errorlevel% equ 0 goto :node_found
echo [!] Node.js is not installed. Installing automatically...
echo.
where winget >nul 2>&1
if %errorlevel% equ 0 (
echo [*] Using winget to install Node.js LTS...
echo ^(A UAC prompt may appear — click YES^)
echo.
winget install --id OpenJS.NodeJS.LTS --accept-source-agreements --accept-package-agreements --silent
if !errorlevel! equ 0 (
for /f "tokens=*" %%i in ('where /r "C:\Program Files\nodejs" node.exe 2^>nul') do set "NP=%%~dpi"
if defined NP set "PATH=!NP!;!PATH!"
goto :node_found
)
)
echo [*] Downloading Node.js installer via PowerShell...
set "INST=%TEMP%\node-installer.msi"
powershell -NoProfile -Command "Invoke-WebRequest -Uri 'https://nodejs.org/dist/lts/node-v20.19.0-x64.msi' -OutFile '%INST%' -UseBasicParsing"
if not exist "%INST%" (
echo.
echo [ERROR] Could not download Node.js.
echo Please install it manually from https://nodejs.org (LTS version)
echo then double-click start.bat again.
echo.
pause
start https://nodejs.org
exit /b 1
)
msiexec /i "%INST%" /passive /norestart
del /q "%INST%" >nul 2>&1
for /f "tokens=*" %%i in ('where /r "C:\Program Files\nodejs" node.exe 2^>nul') do set "NP=%%~dpi"
if defined NP set "PATH=!NP!;!PATH!"
where node >nul 2>&1
if %errorlevel% neq 0 (
echo.
echo [!] Node.js installed but needs a new terminal.
echo Please close this window and double-click start.bat again.
echo.
pause
exit /b 0
)
:node_found
echo [OK] Node.js found:
node -v
echo.
:: ── Step 2: Install server dependencies ───────────────────────────────────
if not exist "node_modules" (
echo [*] Installing server dependencies - first time only...
call npm install
if !errorlevel! neq 0 (
echo [ERROR] npm install failed. Check your internet connection.
pause & exit /b 1
)
echo [OK] Server dependencies installed!
echo.
)
:: ── Step 3: Install client dependencies ───────────────────────────────────
if not exist "client\node_modules" (
echo [*] Installing client dependencies - first time only...
cd client
call npm install
cd ..
if !errorlevel! neq 0 (
echo [ERROR] Client npm install failed.
pause & exit /b 1
)
echo [OK] Client dependencies installed!
echo.
)
:: ── Step 4: Build the UI if needed ────────────────────────────────────────
if not exist "server\public\index.html" (
echo [*] Building UI - first time only, takes ~10 seconds...
cd client
call npx vite build
cd ..
if !errorlevel! neq 0 (
echo [ERROR] UI build failed. Check the client/ folder.
pause & exit /b 1
)
echo [OK] UI built successfully!
echo.
)
:: ── Step 5: Start! ────────────────────────────────────────────────────────
echo ============================================
echo Starting LocalShare...
echo Press Ctrl+C to stop
echo ============================================
echo.
node server/index.js
if %errorlevel% neq 0 (
echo.
echo [ERROR] LocalShare crashed or port 8080 is already in use natively.
pause
) else (
echo.
echo LocalShare stopped.
pause
)