Skip to content

Commit 98e1ac5

Browse files
committed
ADD: updated installer
1 parent a8b0739 commit 98e1ac5

1 file changed

Lines changed: 185 additions & 0 deletions

File tree

installer/openasar_installer.bat

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
@echo off
2+
rem This changes variables from %variable% to !variable! to allow for delayed expansion
3+
rem This is required for the for loops to work properly
4+
setlocal enabledelayedexpansion
5+
6+
rem lil animation, can be skipped by pressing any key 3 times
7+
cls
8+
echo.
9+
echo Installer updated and maintained by GreenMan36#0633
10+
echo.
11+
echo #### ### #### # # ## #### ## ###
12+
echo # # # # # ## # # # # # # # #
13+
echo # # ### #### # # # #### #### #### ###
14+
echo # # # # # ## # # # # # # #
15+
echo #### # #### # # # # # #### # # # #
16+
echo.
17+
C:\Windows\System32\TIMEOUT.exe /t 1 > nul 2> nul
18+
cls
19+
echo.
20+
echo Installer updated and maintained by GreenMan36#0633
21+
echo.
22+
echo ==== === ==== = = == ==== == ===
23+
echo = = = = = == = = = = = = = =
24+
echo = = === ==== = = = ==== ==== ==== ===
25+
echo = = = = = == = = = = = = =
26+
echo ==== = ==== = = = = = ==== = = = =
27+
echo.
28+
C:\Windows\System32\TIMEOUT.exe /t 1 > nul 2> nul
29+
cls
30+
echo.
31+
echo Installer updated and maintained by GreenMan36#0633
32+
echo.
33+
echo .... ... .... . . .. .... .. ...
34+
echo . . . . . .. . . . . . . . .
35+
echo . . ... .... . . . .... .... .... ...
36+
echo . . . . . .. . . . . . . .
37+
echo .... . .... . . . . . .... . . . .
38+
echo.
39+
C:\Windows\System32\TIMEOUT.exe /t 1 > nul 2> nul
40+
cls
41+
42+
rem Discord flavor selection menu
43+
echo.
44+
echo Installer updated and maintained by GreenMan36#0633
45+
echo.
46+
echo Select Discord version:
47+
echo 1. Discord Stable (Default Client)
48+
echo 2. Discord PTB
49+
echo 3. Discord Canary
50+
echo.
51+
set /p "selection=Enter the number corresponding to your selection: "
52+
echo.
53+
54+
if "%selection%"=="1" (
55+
set "discordApp=Discord"
56+
) else if "%selection%"=="2" (
57+
set "discordApp=DiscordPTB"
58+
) else if "%selection%"=="3" (
59+
set "discordApp=DiscordCanary"
60+
) else if "%selection%"=="" (
61+
echo No input detected. Defaulting to Discord Stable.
62+
set "discordApp=Discord"
63+
) else (
64+
color 04
65+
echo Invalid selection. Please try again.
66+
color
67+
pause
68+
exit /b
69+
)
70+
71+
72+
rem Finds the latest version folder for the selected Discord flavor
73+
set "latestVersion="
74+
75+
for /f "delims=" %%d in ('dir /b /ad /on "%localappdata%\%discordApp%\app-*"') do (
76+
set "folderName=%%~nxd"
77+
rem just the version number (without the app- prefix)
78+
set "version=!folderName:~4!"
79+
if "!version!" gtr "!latestVersion!" (
80+
set "latestVersion=!version!"
81+
)
82+
)
83+
84+
rem If no version folders are found, exit. We can't continue
85+
if not defined latestVersion (
86+
color 04
87+
echo No version folders found.
88+
color
89+
pause
90+
exit /b
91+
)
92+
93+
echo Closing Discord... (wait around 3 seconds)
94+
echo.
95+
96+
rem Kills Discord multiple times to make sure it's closed
97+
for /l %%i in (1,1,3) do (
98+
C:\Windows\System32\TASKKILL.exe /f /im %discordApp%.exe > nul 2> nul
99+
)
100+
101+
rem Waits 3 seconds to make sure Discord is fully closed
102+
C:\Windows\System32\TIMEOUT.exe /t 3 /nobreak > nul 2> nul
103+
cls
104+
105+
rem Let the user make sure all info is correct before continuing
106+
echo.
107+
echo Installer updated and maintained by GreenMan36#0633
108+
echo.
109+
echo Confirm the following information before continuing.
110+
echo.
111+
echo Version: %discordApp%
112+
echo App version: %latestVersion%
113+
echo Full path: %localappdata%\%discordApp%\app-%latestVersion%\resources\
114+
echo.
115+
pause
116+
117+
echo Installing OpenAsar... (ignore any flashes, this is a download progress bar)
118+
echo.
119+
echo 1. Backing up original app.asar to app.asar.backup
120+
rem This is done multiple times because there's multiple client mods that use different file names and we support those
121+
copy /y "%localappdata%\%discordApp%\app-%latestVersion%\resources\app.asar" "%localappdata%\%discordApp%\app-%latestVersion%\resources\app.asar.backup" > nul 2> nul
122+
if exist "%localappdata%\%discordApp%\app-%latestVersion%\resources\_app.asar" (
123+
copy /y "%localappdata%\%discordApp%\app-%latestVersion%\resources\_app.asar" "%localappdata%\%discordApp%\app-%latestVersion%\resources\app.asar.backup" > nul 2> nul
124+
)
125+
if exist "%localappdata%\%discordApp%\app-%version%\resources\app.asar.orig" (
126+
copy /y "%localappdata%\%discordApp%\app-%latestVersion%\resources\app.asar.orig" "%localappdata%\%discordApp%\app-%latestVersion%\resources\app.asar.backup" > nul 2> nul
127+
)
128+
129+
rem If the copy command failed, exit
130+
if errorlevel 1 (
131+
color 04
132+
echo Error: Failed to copy the file.
133+
echo Please check the file paths and try again.
134+
echo.
135+
color
136+
pause
137+
exit
138+
)
139+
140+
rem Download OpenAsar, change the color so the download bar blends in
141+
color 36
142+
echo 2. Downloading OpenAsar
143+
powershell -Command "Invoke-WebRequest https://github.com/GooseMod/OpenAsar/releases/download/nightly/app.asar -OutFile \"$Env:LOCALAPPDATA\%discordApp%\app-%version%\resources\app.asar\"" > nul 2> nul
144+
145+
if exist "%localappdata%\%discordApp%\app-%version%\resources\_app.asar" (
146+
powershell -Command "Invoke-WebRequest https://github.com/GooseMod/OpenAsar/releases/download/nightly/app.asar -OutFile \"%localappdata%\%discordApp%\app-%version%\resources\_app.asar\"" > nul 2> nul
147+
)
148+
if exist "%localappdata%\%discordApp%\app-%version%\resources\app.asar.orig" (
149+
powershell -Command "Invoke-WebRequest https://github.com/GooseMod/OpenAsar/releases/download/nightly/app.asar -OutFile \"%localappdata%\%discordApp%\app-%version%\resources\app.asar.orig\"" > nul 2> nul
150+
)
151+
152+
rem If the download command failed, exit
153+
if errorlevel 1 (
154+
color 04
155+
echo Error: Failed to download and replace the asar file.
156+
echo Please check your internet connection. Also make sure that the Discord client is closed.
157+
echo.
158+
color
159+
pause
160+
exit
161+
)
162+
163+
rem Change the color to indicate success and start Discord
164+
cls
165+
color 02
166+
echo.
167+
echo Opening Discord...
168+
start "" "%localappdata%\%discordApp%\Update.exe" --processStart %discordApp%.exe > nul 2> nul
169+
170+
C:\Windows\System32\TIMEOUT.exe /t 1 /nobreak > nul 2> nul
171+
172+
echo.
173+
echo.
174+
echo OpenAsar should be installed! You can check by looking for an "OpenAsar" option in your Discord settings.
175+
echo Not installed? Try restarting Discord, running the script again, joining the OpenAsar Discord or contacting GreenMan36#0633 on Discord.
176+
echo.
177+
echo Installer updated and maintained by GreenMan36#0633
178+
echo Also check out some of my other projects at [GreenMan36.github.io](https://GreenMan36.github.io)
179+
echo.
180+
181+
echo.
182+
pause
183+
color
184+
185+
exit /b

0 commit comments

Comments
 (0)