forked from YuKi-dev1/luatoolsinstaller
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLuaToolsSetup.ps1
More file actions
297 lines (242 loc) · 9.85 KB
/
Copy pathLuaToolsSetup.ps1
File metadata and controls
297 lines (242 loc) · 9.85 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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
Write-Host "Script obsoleto! Procure outra maneira de instalar o LuaTools" -ForegroundColor Yellow
exit 1
## ================== CONFIG ==================
Clear-Host
$Host.UI.RawUI.WindowTitle = "Luatools Setup | .gg/luatools"
$name = "luatools"
$link = "https://github.com/madoiscool/ltsteamplugin/releases/latest/download/ltsteamplugin.zip"
$milleniumTimer = 3
$version = "v1.0.7 hotfix do hotfix e avisos"
$dllSteamTools = "dwmapi.dll"
## ================ ADMIN CHECK ================
function Ensure-Admin {
$currentUser = [Security.Principal.WindowsIdentity]::GetCurrent()
$principal = New-Object Security.Principal.WindowsPrincipal($currentUser)
if (-not $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Host "Tenta de novo e abre O POWERSHELL como ADMINISTRADOR!" -ForegroundColor Red
for ($i = 10; $i -ge 1; $i--) {
Write-Host "Vou te fazer o favor de fechar essa janela em $i..." -ForegroundColor Yellow -NoNewline
Start-Sleep 1
Write-Host "`r" -NoNewline
}
Write-Host ""
exit
}
}
Ensure-Admin
## ================== INTERNAL ==================
$steam = (Get-ItemProperty "HKLM:\SOFTWARE\WOW6432Node\Valve\Steam").InstallPath
$upperName = $name.Substring(0, 1).ToUpper() + $name.Substring(1).ToLower()
$ProgressPreference = 'SilentlyContinue'
## ================== LANGUAGE ==================
$lang = "BR"
## ================== HEADER MSG ==================
Write-Host "====================================================" -ForegroundColor White
Write-Host ""
Write-Host " Bem-vindo ao Instalador Caminho Facil do LuaTools" -ForegroundColor Cyan
Write-Host " Se vc pagou por esse script, vc foi enganado :)" -ForegroundColor Cyan
Write-Host ""
Write-Host "====================================================" -ForegroundColor White
Start-Sleep 1
Write-Host ""
Write-Host " SE APARECER ALGUM ERRO ESTRANHO" -ForegroundColor Red
Write-Host " E SE A STEAM NAO ABRIR" -ForegroundColor Red
Write-Host " Tira print de TODAS as mensagem dessa tela" -ForegroundColor Yellow
Write-Host " E manda em discord.com/invite/luatools" -ForegroundColor Yellow
Write-Host ""
Write-Host "====================================================" -ForegroundColor White
Start-Sleep 4
Write-Host " Preparando para instalar..." -ForegroundColor Green -NoNewline
$headerTimer = 3
for ($i = $headerTimer; $i -gt -1; $i--) {
Write-Host " $i segundo(s)" -ForegroundColor Magenta -NoNewline
Start-Sleep 1
Write-Host "`r Preparando para instalar..." -ForegroundColor Green -NoNewline
}
Write-Host ""
Write-Host "====================================================" -ForegroundColor White
Write-Host ""
## ================== CONFIG ==================
$T = @{
EN = @{
STEAMTOOLS_OK = "Steamtools already installed"
STEAMTOOLS_MISSING = "Steamtools not found."
STEAMTOOLS_INSTALL = "Steamtools reinstalled successfully"
INSTALLING_ST = "Installing Steamtools"
INSTALL_FAIL = "Steamtools installation failed, retrying..."
MILL_MISSING = "Millenium not found, installation will start in 5 seconds."
INSTALL_CANCEL = "Installation cancelled by user."
MILL_OK = "Millenium already installed"
DOWNLOADING = "Downloading"
UNZIPPING = "Unzipping"
INSTALLED = "installed"
PLUGIN_ENABLED = "Plugin enabled"
STARTING_STEAM = "Starting Steam"
WAIT = "Don't close the script yet"
DONE = "Job done, you can close this."
ANTI_VIRUS_ON = "Antivirus turned on."
ANTI_VIRUS_OFF = "Antivirus turned off."
err_anti = "ANTIVIRUS ERROR"
Exclusion = "ADDING AN EXCLUSION TO THE FOLDER C:\Program Files (x86)\Steam"
WAITFEWSECONDS = "Please wait a few seconds for Steam to fully load."
exclusion_in_pc = "Exclusion already exists"
millenium = "Millenium issues."
stop_steam1 = ""
stop_steam2 = ""
millenium_log = ""
}
BR = @{
STEAMTOOLS_OK = "Steamtools ja esta instalado"
STEAMTOOLS_MISSING = "Steamtools nao encontrado."
STEAMTOOLS_INSTALL = "Steamtools reinstalado com sucesso."
INSTALLING_ST = "Instalando Steamtools"
INSTALL_FAIL = "Falha ao instalar Steamtools, tentando novamente..."
MILL_MISSING = "Millenium nao encontrado, instalacao comecara em 5 segundos."
INSTALL_CANCEL = "Instalacao cancelada pelo usuario."
MILL_OK = "Millenium ja instalado"
DOWNLOADING = "Baixando"
UNZIPPING = "Extraindo"
INSTALLED = "instalado"
PLUGIN_ENABLED = "Plugin ativado"
STARTING_STEAM = "Iniciando Steam"
WAIT = "Nao feche o script ainda. Verifica se deu bom e manda print se deu ruim."
DONE = "Tudo feito."
ANTI_VIRUS_ON = "AntiVirus ligado."
ANTI_VIRUS_OFF = "AntiVirus desligado."
err_anti = "ERRO NO ANTIVIRUS"
Exclusion = "ADICIONANDO UMA EXCLUSÃO NA PASTA C:\Program Files (x86)\Steam"
WAITFEWSECONDS = "Aguarde uns segundos ate a Steam abrir completamente"
exclusion_in_pc = "Exclusao ja existe"
millenium = "Erro ao tentar instalar o Millenium."
stop_steam1 = "Fechei a Steam pra instalar tudo tranquilo."
stop_steam2 = "No final vou abrir de novo."
millenium_log = "O Millenium vai falar em english, pode ignorar de boa."
}
}
function L { param($k) return $T[$lang][$k] }
## ================== LOG ==================
function Log {
param ([string]$Type, [string]$Message)
$colors = @{
OK = "Green"; INFO = "Cyan"; ERR = "Red"; WARN = "Yellow"; LOG = "Magenta"; AUX = "DarkGray"; VERSION = "DarkYellow"
}
$date = Get-Date -Format "HH:mm:ss"
Write-Host "[$date] " -NoNewline -ForegroundColor Cyan
Write-Host "[$Type] $Message" -ForegroundColor $colors[$Type]
}
$steamExclusion = "C:\Program Files (x86)\Steam"
try {
$exclusions = @((Get-MpPreference).ExclusionPath)
if ($exclusions -contains $steamExclusion) {
Log "INFO" (L "exclusion_in_pc")
}
else {
Add-MpPreference -ExclusionPath $steamExclusion -ErrorAction Stop
Log "LOG" (L "Exclusion")
}
}
catch {
Log "ERR" (L "err_anti")
Log "ERR" $_.Exception.Message
}
Log "VERSION" "$version"
## ================== STOP STEAM ==================
Log "INFO" (L stop_steam1)
Log "INFO" (L stop_steam2)
Get-Process steam -ErrorAction SilentlyContinue | Stop-Process -Force
Start-Sleep 2
## ================== STEAMTOOLS ==================
$pathSteamTools = Join-Path $steam $dllSteamTools
$script = Invoke-RestMethod "https://steam.run"
$filtered = (
($script -split "`n") | Where-Object {
$_ -notmatch "steam\.exe|Start-Sleep|Write-Host|cls|exit"
}
) -join "`n"
for ($i = 0; $i -lt 5; $i++) {
Log "WARN" (L INSTALLING_ST)
Invoke-Expression $filtered *> $null
if (Test-Path $dllSteamTools) { break }
Log "ERR" (L INSTALL_FAIL)
Start-Sleep 2
}
Log "INFO" (L STEAMTOOLS_INSTALL)
## ================== MILLENIUM ==================
$extPath = Join-Path $steam "ext"
if (Test-Path $extPath -PathType Container) {
Remove-Item $extPath -Recurse -Force
} else {
Log "LOG" (L MILL_MISSING)
}
## ====================== ANTIVIRUS OFF ======================
Try {
Set-MpPreference -DisableRealtimeMonitoring $true -ErrorAction Stop
Log "WARN" (L ANTI_VIRUS_OFF)
}
Catch {
Log "ERR" (L err_anti)
}
for ($i = $milleniumTimer; $i -gt 0; $i--) {
Write-Host "$i" -ForegroundColor Magenta -NoNewline
Start-Sleep 1
Write-Host "`r" -NoNewline
}
Log "INFO" (L millenium_log)
Try {
Invoke-Expression "& { $(Invoke-RestMethod 'https://clemdotla.github.io/millennium-installer-ps1/millennium.ps1') } -DontStart -SteamPath '$steam'"
Log "INFO" (L MILL_OK)
} catch {
Log "WARN" (L millenium)
Log "WARN" $_.Exception.Message
}
## ====================== ANTIVIRUS ON ======================
Try {
Set-MpPreference -DisableRealtimeMonitoring $false -ErrorAction Stop
Log "WARN" (L ANTI_VIRUS_ON)
}
Catch {
Log "ERR" (L err_anti)
}
## ================== PLUGIN ==================
$pluginsDir = Join-Path $steam "plugins"
if (!(Test-Path $pluginsDir)) {
New-Item $pluginsDir -ItemType Directory | Out-Null
}
$Path = Join-Path $pluginsDir $name
$tempZip = Join-Path $env:TEMP "$name.zip"
Log "LOG" "$(L DOWNLOADING) $name"
Invoke-WebRequest $link -OutFile $tempZip *> $null
Log "LOG" "$(L UNZIPPING) $name"
Expand-Archive $tempZip $Path -Force *> $null
Remove-Item $tempZip -Force
Log "OK" "$upperName $(L INSTALLED)"
## ================== ENABLE ==================
$configPath = Join-Path $steam "ext/config.json"
if (-not (Test-Path $configPath)) {
New-Item -Path (Split-Path $configPath) -ItemType Directory -Force | Out-Null
$config = [PSCustomObject]@{
plugins = @{
enabledPlugins = @($name)
}
}
}
else {
$config = Get-Content $configPath -Raw -Encoding UTF8 | ConvertFrom-Json
if (-not $config.plugins) {
$config | Add-Member plugins ([PSCustomObject]@{}) -Force
}
if (-not $config.plugins.enabledPlugins) {
$config.plugins.enabledPlugins = @()
}
if ($config.plugins.enabledPlugins -notcontains $name) {
$config.plugins.enabledPlugins += $name
}
}
$config | ConvertTo-Json -Depth 10 | Set-Content $configPath -Encoding UTF8
Log "OK" (L PLUGIN_ENABLED)
## ================== START STEAM ==================
Start-Process (Join-Path $steam "steam.exe") "-clearbeta"
Log "INFO" (L STARTING_STEAM)
Log "OK" (L DONE)
Log "WARN" (L WAIT)
# CREDITS: clem.la, melly, Yuki (boas._.), ookami42