This repository was archived by the owner on Jun 25, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathwindows.bat
More file actions
96 lines (85 loc) · 3.57 KB
/
Copy pathwindows.bat
File metadata and controls
96 lines (85 loc) · 3.57 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
@echo off
title Portable Diffusion
cd /d "%~dp0"
set APP=%~dp0app
set NODE=%APP%\tools\node-win\node.exe
set NPM=%APP%\tools\node-win\npm.cmd
set DIST=%APP%\dist\index.html
set SETUP=%~dp0scripts\setup.ps1
set CUDA_BACKEND=%APP%\backend\win\cuda\sd-cuda.exe
set VULKAN_BACKEND=%APP%\backend\win\vulkan\sd-vulkan.exe
set SERVE=%~dp0scripts\serve.cjs
if "%FRONTEND_PORT%"=="" set FRONTEND_PORT=1420
set SETUP_REASON=
set SETUP_MODE=Repair
:: ── First-time setup check ────────────────────────────────────────────────────
if not exist "%APP%\tools\node-win" set SETUP_MODE=First-Time Setup
if not exist "%NODE%" (
set SETUP_REASON=Portable Node.js is missing.
goto :run_setup
)
if not exist "%NPM%" (
set SETUP_REASON=Portable npm is missing.
goto :run_setup
)
if not exist "%DIST%" (
set SETUP_REASON=Frontend build is missing.
goto :run_setup
)
if exist "%CUDA_BACKEND%" goto :launch
if exist "%VULKAN_BACKEND%" goto :launch
set SETUP_REASON=No backend binary is installed.
goto :run_setup
:run_setup
echo.
echo ============================================================
echo PORTABLE DIFFUSION ^| %SETUP_MODE%
echo ============================================================
echo.
if "%SETUP_MODE%"=="First-Time Setup" (
echo This looks like your first run. Setting up automatically...
) else (
echo Portable Diffusion needs a quick repair before launch.
)
if not "%SETUP_REASON%"=="" echo Reason: %SETUP_REASON%
echo Models are not downloaded during setup. Download or import them in the app.
echo.
echo Press any key to continue, or Ctrl+C to cancel.
pause >nul
:: Clear old frontend and backend server processes before setup so app/tools/node-win can be replaced
for /f "tokens=5" %%a in ('netstat -aon 2^>nul ^| findstr ":%FRONTEND_PORT% "') do taskkill /f /pid %%a >nul 2>nul
for /f "tokens=5" %%a in ('netstat -aon 2^>nul ^| findstr ":8080 "') do taskkill /f /pid %%a >nul 2>nul
powershell -ExecutionPolicy Bypass -File "%SETUP%"
if errorlevel 1 (
echo.
echo [ERROR] Setup failed. Please check the output above.
pause
exit /b 1
)
:: After setup, continue to launch
goto :launch
:: ── Launch ────────────────────────────────────────────────────────────────────
:launch
echo.
echo ============================================================
echo PORTABLE DIFFUSION ^| Launching...
echo ============================================================
echo.
:: Clear frontend and backend ports to prevent address conflicts.
echo Clearing frontend port %FRONTEND_PORT% and backend port 8080...
for /f "tokens=5" %%a in ('netstat -aon 2^>nul ^| findstr ":%FRONTEND_PORT% "') do taskkill /f /pid %%a >nul 2>nul
for /f "tokens=5" %%a in ('netstat -aon 2^>nul ^| findstr ":8080 "') do taskkill /f /pid %%a >nul 2>nul
:: Start frontend server + backend manager (serve.cjs manages sd-vulkan.exe)
echo Starting Portable Diffusion...
echo Opening browser at http://localhost:%FRONTEND_PORT%...
start /b cmd /c "timeout /t 2 >nul && start http://localhost:%FRONTEND_PORT%"
echo.
echo ============================================================
echo Running!
echo Web UI: http://localhost:%FRONTEND_PORT%
echo GPU API: Auto-selected by the app (starts at 8080)
echo.
echo Press Ctrl+C in this window to stop all services.
echo ============================================================
echo.
"%NODE%" "%SERVE%"