-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstaller.bat
More file actions
137 lines (115 loc) · 3.55 KB
/
installer.bat
File metadata and controls
137 lines (115 loc) · 3.55 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
@echo off
setlocal enabledelayedexpansion
title Huffman Encoder - Installer
cd /d "%~dp0"
echo.
echo ========================================
echo Huffman Encoder - Installation
echo ========================================
echo.
REM Check if Java is installed
java -version >nul 2>&1
if errorlevel 1 (
echo ERROR: Java 21 or later is not installed or not in your system PATH.
echo Please install Java from: https://www.oracle.com/java/technologies/downloads/
echo.
pause
exit /b 1
)
REM Check if compilation is needed
if not exist "bin" (
echo.
echo The project needs to be compiled before installation.
echo This will compile all Java source files to the 'bin' directory.
echo.
set /p compile_consent="Do you want to compile now? (Y/N): "
if /i not "!compile_consent!"=="Y" (
echo Compilation skipped. Installation cannot continue.
pause
exit /b 1
)
echo.
echo Compiling project...
echo.
mkdir bin 2>nul
REM Find all Java files and compile them
setlocal enabledelayedexpansion
set "files="
for /r HuffmanEncoder\src %%f in (*.java) do (
set "files=!files! "%%f""
)
if "!files!"=="" (
echo ERROR: No Java files found in HuffmanEncoder\src directory.
pause
exit /b 1
)
javac -d bin -cp "HuffmanEncoder\src;HuffmanEncoder\lib\*" !files!
REM Check if compilation actually produced .class files
if not exist "bin\huffman\Main.class" (
echo.
echo ERROR: Compilation failed. No .class files were generated.
echo.
pause
exit /b 1
)
if errorlevel 1 (
echo.
echo ERROR: Compilation failed. Please check your Java installation.
echo.
pause
exit /b 1
)
echo Compilation successful!
echo.
)
echo This will create a desktop shortcut for
echo the Huffman Encoder application.
echo.
echo Location: %USERPROFILE%\Desktop\Huffman Encoder.lnk
echo.
set /p consent="Do you want to continue? (Y/N): "
if /i not "%consent%"=="Y" (
echo Installation cancelled.
pause
exit /b
)
echo.
echo Installing...
echo.
REM Get the full path to this batch file
for /f "delims=" %%A in ('cd') do set "ProjectPath=%%A"
set "LaunchPath=%ProjectPath%\launch.bat"
REM Escape backslashes for VBScript
set "LaunchPathEscaped=%LaunchPath:\=\\%"
set "ProjectPathEscaped=%ProjectPath:\=\\%"
REM Create VBScript to generate shortcut
set "VBScript=%temp%\CreateShortcut.vbs"
(
echo Set oWS = WScript.CreateObject("WScript.Shell"^)
echo sLinkFile = "%USERPROFILE%\Desktop\Huffman Encoder.lnk"
echo Set oLink = oWS.CreateShortcut(sLinkFile^)
echo oLink.TargetPath = "%LaunchPath%"
echo oLink.WorkingDirectory = "%ProjectPath%"
echo oLink.Description = "Huffman Encoder - Text Compression Tool"
echo oLink.IconLocation = "%LaunchPath%"
echo oLink.Save
) > "%VBScript%"
REM Execute VBScript
cscript.exe /nologo "%VBScript%"
if exist "%USERPROFILE%\Desktop\Huffman Encoder.lnk" (
echo.
echo ========================================
echo Installation successful!
echo ========================================
echo.
echo A shortcut has been created on your desktop.
echo You can now launch Huffman Encoder from the desktop.
echo.
) else (
echo.
echo Installation failed. Could not create shortcut.
echo.
)
REM Cleanup
del "%VBScript%" 2>nul
pause