-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathInstall FreeGSTBill.bat
More file actions
273 lines (242 loc) · 9.95 KB
/
Copy pathInstall FreeGSTBill.bat
File metadata and controls
273 lines (242 loc) · 9.95 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
@echo off
setlocal enabledelayedexpansion
title Free GST Billing Software - Installer
color 0B
echo.
echo ========================================================
echo.
echo Free GST Billing Software
echo Free - Offline - Open Source
echo by DiceCodes
echo.
echo ========================================================
echo.
cd /d "%~dp0"
:: ========================================
:: Step 1: Check / Install Node.js
:: ========================================
echo [1/4] Checking Node.js...
where node >nul 2>nul
if %errorlevel% neq 0 (
echo.
echo Node.js not found. Installing automatically...
echo.
:: Try winget first (Windows 10 1709+ and Windows 11)
where winget >nul 2>nul
if %errorlevel% equ 0 (
echo Installing Node.js LTS via winget...
echo (This may take 1-2 minutes, please wait)
echo.
winget install OpenJS.NodeJS.LTS --accept-source-agreements --accept-package-agreements --silent
if %errorlevel% equ 0 (
echo.
echo Node.js installed successfully!
echo.
echo IMPORTANT: Please close this window and run the installer again.
echo (Windows needs to refresh the PATH to find Node.js)
echo.
pause
exit /b 0
) else (
echo winget install failed. Trying alternative method...
)
)
:: Try chocolatey
where choco >nul 2>nul
if %errorlevel% equ 0 (
echo Installing Node.js LTS via Chocolatey...
choco install nodejs-lts -y --no-progress
if %errorlevel% equ 0 (
echo.
echo Node.js installed successfully!
echo Please close this window and run the installer again.
echo.
pause
exit /b 0
)
)
:: Fallback: download MSI installer directly
echo.
echo Automatic install not available. Downloading Node.js installer...
echo.
set "NODE_MSI=%TEMP%\node-install.msi"
echo Downloading Node.js LTS...
powershell -Command "try { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $url = (Invoke-WebRequest -Uri 'https://nodejs.org/dist/latest-v22.x/' -UseBasicParsing).Links | Where-Object { $_.href -match 'x64\.msi$' } | Select-Object -First 1 -ExpandProperty href; Invoke-WebRequest -Uri ('https://nodejs.org/dist/latest-v22.x/' + $url) -OutFile '%NODE_MSI%' -UseBasicParsing; Write-Host 'Download complete' } catch { Write-Host 'DOWNLOAD_FAILED' }" 2>nul
if exist "%NODE_MSI%" (
echo Running Node.js installer...
echo (Follow the installer steps - click Next through all)
echo.
start /wait msiexec /i "%NODE_MSI%"
del "%NODE_MSI%" 2>nul
echo.
echo Please close this window and run the installer again.
echo (Windows needs to refresh the PATH to find Node.js)
echo.
pause
exit /b 0
) else (
echo [!] Could not download Node.js automatically.
echo.
echo Please install Node.js manually:
echo 1. Go to: https://nodejs.org
echo 2. Download the LTS version
echo 3. Run the installer
echo 4. Run this installer again
echo.
start https://nodejs.org/en/download/
pause
exit /b 1
)
)
for /f "tokens=*" %%v in ('node -v') do set NODE_VER=%%v
echo Found Node.js %NODE_VER%
echo.
:: ========================================
:: Step 2: Install dependencies
:: ========================================
echo [2/4] Installing dependencies...
if exist "node_modules" (
echo Dependencies already installed
) else (
echo Running npm install (this may take 1-2 minutes)...
npm install --silent 2>nul
if %errorlevel% neq 0 (
echo [!] Failed to install dependencies. Check your internet connection.
pause
exit /b 1
)
echo Dependencies installed
)
echo.
:: ========================================
:: Step 3: Build the application
:: ========================================
echo [3/4] Building application...
if exist "dist\index.html" (
echo Application already built
) else (
npm run build --silent 2>nul
if %errorlevel% neq 0 (
echo [!] Build failed. Please check for errors above.
pause
exit /b 1
)
echo Build complete
)
echo.
:: ========================================
:: Step 4: Create Desktop Shortcut
:: ========================================
echo [4/5] Creating shortcuts...
set "TARGET_PATH=%~dp0Start FreeGSTBill.bat"
:: Desktop shortcut
set "DESKTOP_SHORTCUT=%USERPROFILE%\Desktop\Free GST Billing Software.lnk"
:: Start Menu shortcut (searchable from Windows Start)
set "STARTMENU_DIR=%APPDATA%\Microsoft\Windows\Start Menu\Programs\Free GST Billing Software"
if not exist "%STARTMENU_DIR%" mkdir "%STARTMENU_DIR%"
set "STARTMENU_SHORTCUT=%STARTMENU_DIR%\Free GST Billing Software.lnk"
:: Create VBS shortcut creator script (creates both shortcuts)
set "TEMP_VBS=%TEMP%\create_shortcut.vbs"
(
echo Set WshShell = WScript.CreateObject("WScript.Shell"^)
echo.
echo Set desktopShortcut = WshShell.CreateShortcut("%DESKTOP_SHORTCUT%"^)
echo desktopShortcut.TargetPath = "%TARGET_PATH%"
echo desktopShortcut.WorkingDirectory = "%~dp0"
echo desktopShortcut.Description = "Free GST Billing Software"
echo desktopShortcut.WindowStyle = 1
echo desktopShortcut.Save
echo.
echo Set startShortcut = WshShell.CreateShortcut("%STARTMENU_SHORTCUT%"^)
echo startShortcut.TargetPath = "%TARGET_PATH%"
echo startShortcut.WorkingDirectory = "%~dp0"
echo startShortcut.Description = "Free GST Billing Software"
echo startShortcut.WindowStyle = 1
echo startShortcut.Save
) > "%TEMP_VBS%"
cscript //nologo "%TEMP_VBS%" 2>nul
del "%TEMP_VBS%" 2>nul
if exist "%DESKTOP_SHORTCUT%" (
echo Desktop shortcut created
) else (
echo Could not create desktop shortcut
)
if exist "%STARTMENU_SHORTCUT%" (
echo Start Menu shortcut created (search "Free GST Billing" in Start)
) else (
echo Could not create Start Menu shortcut
)
echo.
:: ========================================
:: Step 5: Auto-start on Windows login + Protocol
:: ========================================
echo [5/5] Setting up auto-start...
:: Add to Windows Startup folder (server starts silently on login)
set "STARTUP_DIR=%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup"
set "STARTUP_SHORTCUT=%STARTUP_DIR%\Free GST Billing Server.lnk"
set "SERVER_BAT=%~dp0start-server-silent.bat"
:: Create a silent server starter (no window, just runs node)
(
echo @echo off
echo cd /d "%~dp0"
echo if not exist "node_modules" exit /b
echo if not exist "dist\index.html" exit /b
echo start "" /min cmd /c "node server.js"
) > "%SERVER_BAT%"
:: Create startup shortcut
set "TEMP_VBS2=%TEMP%\create_startup.vbs"
(
echo Set WshShell = WScript.CreateObject("WScript.Shell"^)
echo Set startupShortcut = WshShell.CreateShortcut("%STARTUP_SHORTCUT%"^)
echo startupShortcut.TargetPath = "%SERVER_BAT%"
echo startupShortcut.WorkingDirectory = "%~dp0"
echo startupShortcut.Description = "Free GST Billing Software Server Auto-Start"
echo startupShortcut.WindowStyle = 7
echo startupShortcut.Save
) > "%TEMP_VBS2%"
cscript //nologo "%TEMP_VBS2%" 2>nul
del "%TEMP_VBS2%" 2>nul
if exist "%STARTUP_SHORTCUT%" (
echo Auto-start on login enabled
) else (
echo Could not enable auto-start
)
:: Register freegstbill:// protocol (so browser "Start Server" button works)
powershell -Command "New-Item -Path 'HKCU:\Software\Classes\freegstbill' -Force | Out-Null; Set-ItemProperty -Path 'HKCU:\Software\Classes\freegstbill' -Name '(default)' -Value 'URL:Free GST Billing Protocol'; New-ItemProperty -Path 'HKCU:\Software\Classes\freegstbill' -Name 'URL Protocol' -Value '' -Force | Out-Null; New-Item -Path 'HKCU:\Software\Classes\freegstbill\shell\open\command' -Force | Out-Null; Set-ItemProperty -Path 'HKCU:\Software\Classes\freegstbill\shell\open\command' -Name '(default)' -Value '%TARGET_PATH%'" 2>nul
echo Start button registered
:: Register freegstbill-update:// protocol (so browser "Update Now" button works)
set "UPDATE_PATH=%~dp0Update FreeGSTBill.bat"
powershell -Command "New-Item -Path 'HKCU:\Software\Classes\freegstbill-update' -Force | Out-Null; Set-ItemProperty -Path 'HKCU:\Software\Classes\freegstbill-update' -Name '(default)' -Value 'URL:Free GST Billing Update Protocol'; New-ItemProperty -Path 'HKCU:\Software\Classes\freegstbill-update' -Name 'URL Protocol' -Value '' -Force | Out-Null; New-Item -Path 'HKCU:\Software\Classes\freegstbill-update\shell\open\command' -Force | Out-Null; Set-ItemProperty -Path 'HKCU:\Software\Classes\freegstbill-update\shell\open\command' -Name '(default)' -Value '%UPDATE_PATH%'" 2>nul
echo Update button registered
echo.
:: ========================================
:: Done!
:: ========================================
echo.
echo ========================================================
echo.
echo Installation Complete!
echo.
echo ========================================================
echo.
echo Starting Free GST Billing Software...
echo (Your browser will open automatically)
echo.
start "" "%~dp0Start FreeGSTBill.bat"
echo.
echo ========================================================
echo.
echo Free GST Billing Software is running!
echo.
echo HOW IT WORKS:
echo - Server starts automatically when you turn on PC
echo - Just click "Free GST Billing Software" on Desktop to open
echo - Or search "Free GST Billing" in Start Menu
echo - Your data is always safe on your computer
echo.
echo Tip: When the app opens, click "Install App"
echo to use it like a normal desktop application.
echo.
echo ========================================================
echo.
pause