-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInstaller.bat
111 lines (95 loc) · 3.26 KB
/
Installer.bat
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
@echo off
:: Get all parameters passed to the script
set "install=%*"
:: If an installation directory is not specified, use the default
if "%install%" EQU "" (
set "install=%LocalAppData%\Programs\ACES Equipment Builder"
)
:: Keep the VSCode extension up to date
set "vsExtension=%~dp0aces-eb-language-support.vsix"
set "vsExtVersion=1.0.2"
if exist "%vsExtension%" call :vscode
:: Safety check
if "%install%" EQU "%~dp0install" (
echo ACES EB is already up to date!
echo Press any key to exit.
pause >nul
exit
)
setlocal EnableDelayedExpansion
:: Retrieve properties from the previous configuration file
set "conf=%install%\config.txt"
set "exists=0"
set "Developer="
set "VersionTag="
set "WebCTRLPath="
set "AutoSync="
set "SyncLibrary="
set "SyncFavorites="
set "SyncScripts="
if exist "%conf%" (
set "exists=1"
for /f "usebackq tokens=1,* delims==" %%i in ("%conf%") do (
set "%%i=%%j"
)
)
:: Copy installation files to the specified directory
robocopy "%~dp0install" "%install%" /MIR /XD "%~dp0install\lib" "%install%\lib" /XF "%~dp0install\log.txt" "%install%\log.txt"
:: Write a few of the old properties to the new configuration file
if "%exists%" EQU "1" (
echo.
if "!WebCTRLPath!" NEQ "" echo WebCTRLPath=!WebCTRLPath!
if "!Developer!" NEQ "" echo Developer=!Developer!
if "!VersionTag!" NEQ "" echo VersionTag=!VersionTag!
if "!AutoSync!" NEQ "" echo AutoSync=!AutoSync!
if "!SyncLibrary!" NEQ "" echo SyncLibrary=!SyncLibrary!
if "!SyncFavorites!" NEQ "" echo SyncFavorites=!SyncFavorites!
if "!SyncScripts!" NEQ "" echo SyncScripts=!SyncScripts!
) >> "%conf%"
endlocal
:: Create a shortbut to "ACES Equipment Builder.exe" on the desktop
set "shortcut=%USERPROFILE%\Desktop\ACES Equipment Builder.lnk"
set "shortcutVBS=%Temp%\ShortcutCreator.vbs"
if exist "%shortcut%" (
del /f /q "%shortcut%"
)
call :createShortcut "%shortcut%" "%install%\ACES Equipment Builder.exe"
echo Operation completed.
:: Launch the application
echo CreateObject^("WScript.Shell"^).Run """%install%\jre\bin\java"" -cp ""%install%\ACES Equipment Builder.jar"" ACESEquipmentBuilder", 0, FALSE > "%install%\launcher.vbs"
wscript "%install%\launcher.vbs"
del /F "%install%\launcher.vbs" >nul 2>nul
timeout /t 1 >nul
exit
:: Create a shortbut to "ACES Equipment Builder.exe" on the desktop
:createShortcut
(
echo Set ws = WScript.CreateObject^("WScript.Shell"^)
echo Set link = ws.CreateShortcut^("%~1"^)
echo link.TargetPath = "%~2"
echo link.Save
)>"%shortcutVBS%"
wscript "%shortcutVBS%"
if exist "%shortcutVBS%" (
del /f /q "%shortcutVBS%"
)
exit /b
:: OPTIONAL function which could be used to auto-update the corresponding VSCode extension
:vscode
call code --version >nul 2>nul
if "%ERRORLEVEL%" EQU "0" (
echo Examining VSCode installation...
setlocal EnableDelayedExpansion
set "ver="
for /f "tokens=2 delims=@" %%i in ('code --list-extensions --show-versions ^| findstr /L "ACES.aces-eb-language-support@"') do (
set "ver=%%i"
)
if "!ver!" NEQ "%vsExtVersion%" (
if "!ver!" NEQ "" (
call code --uninstall-extension ACES.aces-eb-language-support
)
call code --install-extension "%vsExtension%"
)
endlocal
)
exit /b