Repository navigation
Expand file tree
/
Copy pathAmongUsModTORplusDeployScript.ps1
More file actions
6055 lines (5650 loc) · 303 KB
/
Copy pathAmongUsModTORplusDeployScript.ps1
File metadata and controls
6055 lines (5650 loc) · 303 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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Param(
$Args1, #skipconfirmation
[switch]$DebugMode,
[string]$DeployPlatform,
[switch]$BatchChild,
[string]$ProgressSyncFile,
[string]$ChildLogPath,
[int]$TargetLatestFlag = 0
)
$ScriptStartTime = Get-Date
$Log = $ScriptStartTime.ToString("yyyy/MM/dd HH:mm:ss.fff") + " "
################################################################################################
#
# Among Us Mod Auto Deploy Script
#
$version = "3.0.0"
$build = "2026101004"
#
#################################################################################################
Write-Output "$Log PS1 Loading Start $version -$build"
### 未確認Modについては "NONE"で統一する
### Minimum versions (currently active) v19
$ermin = "v2026.9.30.0"
$esmin = "v2026.9.30.0"
$tormin = "NONE"
$tourmin = "NONE"
$tohmin = "v5.1.13"
$snrmin = "3.3.0.0"
$lmmin = "4.0.1"
$nosmin = "110"
$toymin = "NONE"
$sramin = "v2026.10.8"
### minimum version for 2026.8.18 v18
$ermin1 = "v2026.8.19.0"
$esmin1 = "v2026.8.19.0"
$tormin1 = "NONE"
$tourmin1 = "NONE"
$tohmin1 = "NONE"
$snrmin1 = "3.2.0.0"
$lmmin1 = "3.9.3"
$nosmin1 = "109"
$toymin1 = "NONE"
$sramin1 = "v2025.6.11"
### minimum version for 2026.6.5 v17
$ermin2 = "v2025.9.10.0"
$esmin2 = "v2025.9.10.0"
$tormin2 = "NONE"
$tourmin2 = "NONE"
$tohmin2 = "v5.1.13"
$snrmin2 = "3.1.0.0"
$lmmin2 = "3.9.0"
$nosmin2 = "107"
$toymin2 = "NONE"
$sramin2 = "v2025.6.8"
#Frequent changing parameter https://steamdb.info/depot/945361/manifests/
# Current versions:
#$prever1 = "2025.6.10"
#$prevtargetid1 = "1298083356997541927"
#$prever1 = "2025.9.9"
#$prevtargetid1 = "4146372421172743268"
#$prever1 = "2026.2.17"
#$prevtargetid1 = "8416065559776121687"
$prever1 = "2026.6.5"
$prevtargetid1 = "7623608153396667062"
$prever0 = "2026.8.18"
$prevtargetid0 = "1397756378225229500"
#2026.9.29 990035194164819049 v19
$script:nosFallbackTag = "v3.5.3.6"
$gmhbool = $false #flag for Test
#Testdll: Snapshot 22.11.21c
#$torgmdll = "https://github.com/Dolly1016/Nebula/releases/download/snapshot/Nebula.dll"
$debugform = $false
$icorenew = $false
#TOR plus, TOR GM, TOR GMH, AUM ,TOR, TOU-R, TOYis depricated.
$PSDefaultParameterValues['Out-File:Encoding'] = 'utf8'
$ProgressPreference = 'SilentlyContinue'
#################################################################################################
# Version Manifest Loader (GitHub Raw / Local Fallback)
#################################################################################################
function Initialize-VersionManifest {
$manifestUrl = "https://raw.githubusercontent.com/Maximilian2022/AmongUs-Mod-Auto-Deploy-Script/main/config/version_manifest.json"
$baseDir = if ($PSScriptRoot) { $PSScriptRoot } elseif ($PSCommandPath) { Split-Path -Parent $PSCommandPath } else { (Get-Location).Path }
$localManifestPath = if ($baseDir) { Join-Path $baseDir "config\version_manifest.json" } else { $null }
$rawJson = $null
$sourceLabel = "Built-in Fallback"
if (-not [string]::IsNullOrWhiteSpace($env:AUMADS_MANIFEST_JSON)) {
$rawJson = $env:AUMADS_MANIFEST_JSON
$sourceLabel = "Parent Cache"
}
elseif (($env:AUMADS_USE_LOCAL_MANIFEST -eq "1") -and ($localManifestPath) -and (Test-Path $localManifestPath)) {
try {
$rawJson = [System.IO.File]::ReadAllText($localManifestPath, [System.Text.Encoding]::UTF8)
$sourceLabel = "Local File ($localManifestPath)"
}
catch {}
}
else {
try {
$resp = Invoke-WebRequest -Uri $manifestUrl -UseBasicParsing -TimeoutSec 5 -ErrorAction Stop
if (($null -ne $resp) -and (-not [string]::IsNullOrWhiteSpace($resp.Content))) {
$rawJson = $resp.Content
$sourceLabel = "GitHub Raw"
}
}
catch {
if (($localManifestPath) -and (Test-Path $localManifestPath)) {
try {
$rawJson = [System.IO.File]::ReadAllText($localManifestPath, [System.Text.Encoding]::UTF8)
$sourceLabel = "Local Fallback ($localManifestPath)"
}
catch {}
}
}
}
if ([string]::IsNullOrWhiteSpace($rawJson)) {
Write-Output "$Log Version Manifest: $sourceLabel"
return
}
try {
$manifest = $rawJson | ConvertFrom-Json -ErrorAction Stop
if ($null -eq $manifest) { return }
if ($manifest.amongUs) {
if (($manifest.amongUs.prev0) -and (-not [string]::IsNullOrWhiteSpace($manifest.amongUs.prev0.gameVer))) {
$script:prever0 = [string]$manifest.amongUs.prev0.gameVer
}
if (($manifest.amongUs.prev0) -and (-not [string]::IsNullOrWhiteSpace($manifest.amongUs.prev0.manifestId))) {
$script:prevtargetid0 = [string]$manifest.amongUs.prev0.manifestId
}
if (($manifest.amongUs.prev1) -and (-not [string]::IsNullOrWhiteSpace($manifest.amongUs.prev1.gameVer))) {
$script:prever1 = [string]$manifest.amongUs.prev1.gameVer
}
if (($manifest.amongUs.prev1) -and (-not [string]::IsNullOrWhiteSpace($manifest.amongUs.prev1.manifestId))) {
$script:prevtargetid1 = [string]$manifest.amongUs.prev1.manifestId
}
}
if ($manifest.mods) {
$modVarMap = @{
"ER" = @("ermin", "ermin1", "ermin2")
"ER+ES" = @("esmin", "esmin1", "esmin2")
"TOR" = @("tormin", "tormin1", "tormin2")
"TOU-R" = @("tourmin", "tourmin1", "tourmin2")
"TOH" = @("tohmin", "tohmin1", "tohmin2")
"SNR" = @("snrmin", "snrmin1", "snrmin2")
"LM" = @("lmmin", "lmmin1", "lmmin2")
"NOS" = @("nosmin", "nosmin1", "nosmin2")
"TOY" = @("toymin", "toymin1", "toymin2")
"SRA" = @("sramin", "sramin1", "sramin2")
}
foreach ($modKey in $modVarMap.Keys) {
$modCfg = $manifest.mods.$modKey
if ($null -ne $modCfg) {
$varNames = $modVarMap[$modKey]
if (-not [string]::IsNullOrWhiteSpace($modCfg.latest)) {
Set-Variable -Name $varNames[0] -Value ([string]$modCfg.latest) -Scope Script
}
if (-not [string]::IsNullOrWhiteSpace($modCfg.prev0)) {
Set-Variable -Name $varNames[1] -Value ([string]$modCfg.prev0) -Scope Script
}
if (-not [string]::IsNullOrWhiteSpace($modCfg.prev1)) {
Set-Variable -Name $varNames[2] -Value ([string]$modCfg.prev1) -Scope Script
}
if (($modKey -eq "NOS") -and (-not [string]::IsNullOrWhiteSpace($modCfg.fallbackTag))) {
$script:nosFallbackTag = [string]$modCfg.fallbackTag
}
}
}
}
$env:AUMADS_MANIFEST_JSON = $rawJson
Write-Output "$Log Version Manifest Loaded ($sourceLabel / updatedAt=$($manifest.updatedAt))"
}
catch {
Write-Output "$Log Version Manifest Parse Fallback: $_"
}
}
Initialize-VersionManifest
#################################################################################################
# Translate Function with Caching
#################################################################################################
$Cult = Get-Culture
$TranslationCache = @{}
$gmhweb = $null
$mrweb = $null
$torweb = $null
$tourweb = $null
$sraweb = $null
$erweb = $null
$nosweb = $null
$lmweb = $null
$snrweb = $null
$tohweb = $null
$toyweb = $null
$rhrweb = $null
$amsweb = $null
$transenabled = $true
#$Cult = "en-US"
function Get-Translate($transtext) {
if ($Cult -ne "ja-JP") {
if ($transenabled) {
# キャッシュから返す
if ($TranslationCache.ContainsKey($transtext)) {
return $TranslationCache[$transtext]
}
try {
$Uri = "https://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl=$($Cult)&dt=t&q=$transtext"
$Response = (Invoke-WebRequest -Uri $Uri -Method Get -TimeoutSec 5).Content
$Resulttxt = $Response -split '\\r\\n' -replace '^(","?)|(null.*?\[")|\[{3}"' -split '","'
$result = $Resulttxt[0]
# キャッシュに保存
$TranslationCache[$transtext] = $result
return $result
}
catch {
# エラー時はキャッシュに保存して返す
$TranslationCache[$transtext] = $transtext
return $transtext
}
}
else {
return $transtext
}
}
else {
return $transtext
}
}
$Now = Get-Date
$Log = $Now.ToString("yyyy/MM/dd HH:mm:ss.fff") + " "
Write-Output "$Log Loading Done."
if ($Cult -ne "ja-JP") {
if ([System.Windows.Forms.MessageBox]::Show($(Get-Translate("出力されるログもOS言語に翻訳しますか?`r`n有効にすると動作がとても遅くなります。")), "Among Us Mod Auto Deploy Tool", 4) -eq "Yes") {
$transenabled = $true
}
else {
$transenabled = $false
}
}
#################################################################################################
# 権限チェック
#################################################################################################
$Now = Get-Date
$Log = $Now.ToString("yyyy/MM/dd HH:mm:ss.fff") + " "
Write-Output $(Get-Translate("$Log 実行前権限チェック開始"))
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
$principal = New-Object Security.Principal.WindowsPrincipal($identity)
$isAdmin = $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (!$isAdmin) {
$TempMyOutputEncode = [System.Console]::OutputEncoding
[System.Console]::OutputEncoding = [System.Text.Encoding]::GetEncoding('shift_jis')
if (!(((net localgroup Administrators) -contains $env:username ) -or ((net localgroup Administrators) -contains "$env:userdomain\$env:username"))) {
$Now = Get-Date
$Log = $Now.ToString("yyyy/MM/dd HH:mm:ss.fff") + " "
Write-Host $(Get-Translate("$Log このWindowsユーザーアカウントでは本Scriptは動作しません。管理者権限が必要です。"))
Write-Host $(Get-Translate("$Log あなたのユーザー名($env:username)は管理者権限グループに属していません"))
Write-Host $(Get-Translate("$Log 管理者権限グループに属しているユーザーは以下の通りです"))
$nn = net localgroup Administrators
Write-Host $nn
pause
Exit
}
[System.Console]::OutputEncoding = $TempMyOutputEncode
}
$Now = Get-Date
$Log = $Now.ToString("yyyy/MM/dd HH:mm:ss.fff") + " "
Write-Output $(Get-Translate("$Log 実行前権限チェック終了"))
#################################################################################################
# Run w/ Powershell v7 if available.
#################################################################################################
$npl = Get-Location
$npl2 = Get-Location
$Now = Get-Date
$Log = $Now.ToString("yyyy/MM/dd HH:mm:ss.fff") + " "
Write-Output $(Get-Translate("$Log 実行前チェック開始"))
$hasPwsh = $null -ne (Get-Command pwsh -ErrorAction SilentlyContinue) -or (Test-Path "$env:ProgramFiles\PowerShell\7\pwsh.exe")
if (!$hasPwsh) {
$Now = Get-Date
$Log = $Now.ToString("yyyy/MM/dd HH:mm:ss.fff") + " "
Write-Output $(Get-Translate("$Log 初起動時のみ: Powershell 7を導入中・・・。"))
Start-Process powershell.exe -ArgumentList "-Command Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))" -Verb RunAs -Wait
Write-Output "`r`n"
Start-Process powershell.exe -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command choco upgrade pwsh powershell-core aria2 legendary -y" -Verb RunAs -Wait
Write-Output "`r`n"
# PATHを再読み込み
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
$pwshExe = if (Test-Path "$env:ProgramFiles\PowerShell\7\pwsh.exe") { "$env:ProgramFiles\PowerShell\7\pwsh.exe" } else { "pwsh.exe" }
$pwshArgs = "-NoProfile -ExecutionPolicy Unrestricted -WindowStyle Minimized -File `"$npl\AmongUsModTORplusDeployScript.ps1`""
if ($null -ne $Args1) { $pwshArgs += " $Args1" }
Start-Process $pwshExe -ArgumentList $pwshArgs -Verb RunAs -Wait
Write-Output "`r`n"
Exit
}
Unblock-File "$npl\AmongUsModTORplusDeployScript.ps1"
$a = [Net.Dns]::GetHostName()
$achk = ($a -match '[^\x00-\x7F]')
if ($achk) {
$Now = Get-Date
$Log = $Now.ToString("yyyy/MM/dd HH:mm:ss.fff") + " "
Write-Output $(Get-Translate("$Log PCの名前に全角が含まれています。Modがうまく起動しない場合があります。英数字への名前変更を推奨します。"))
Start-Process "https://support.lenovo.com/jp/ja/solutions/ht105079"
}
$Now = Get-Date
$Log = $Now.ToString("yyyy/MM/dd HH:mm:ss.fff") + " "
Write-Output $(Get-Translate("$Log 実行前チェック完了"))
$isDebugger = ($env:TERM_PROGRAM -eq "vscode") -or ($null -ne $psISE) -or $DebugMode
if (!$isDebugger -and ((!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole("Administrators")) -or ($PSVersionTable.PSVersion.Major -lt 7))) {
$pwshExe = if (Test-Path "$env:ProgramFiles\PowerShell\7\pwsh.exe") { "$env:ProgramFiles\PowerShell\7\pwsh.exe" } else { "pwsh.exe" }
$pwshArgs = "-NoProfile -ExecutionPolicy Bypass -WindowStyle Minimized -File `"$npl\AmongUsModTORplusDeployScript.ps1`""
if ($null -ne $Args1) { $pwshArgs += " $Args1" }
Start-Process $pwshExe -ArgumentList $pwshArgs -Verb RunAs -Wait
exit
}
#################################################################################################
# Log用Function
#################################################################################################
# ログの出力先
$LogPath = "C:\Temp\AUM_Deploy"
# ログファイル名
$LogName = "AmongUsMod_DeployLog"
$Now = Get-Date
# ログファイル名(XXXX_YYYY-MM-DD.log)
$LogFile = $LogName + "_" + $Now.ToString("yyyy-MM-dd-HH-mm-ss") + ".log"
# ログフォルダーがなかったら作成
if ( -not (Test-Path $LogPath) ) {
New-Item $LogPath -Type Directory
}
# ログファイル名
$LogFileName = Join-Path $LogPath $LogFile
if ($ChildLogPath) {
$LogFileName = $ChildLogPath
}
$scpath = [System.Environment]::GetFolderPath("Desktop")
$WsShell = New-Object -ComObject WScript.Shell
$dsk = "$scpath\AUMADS"
if (!(Test-Path $dsk)) {
New-Item $dsk -Type Directory
}
function Write-Log($logstring) {
$Now = Get-Date
# Log 出力文字列に時刻を付加(YYYY/MM/DD HH:MM:SS.MMM $LogString)
$Log = $Now.ToString("yyyy/MM/dd HH:mm:ss.fff") + " " + $LogString
# ログ出力
Write-Output $(Get-Translate($Log)) | Out-File -FilePath $LogFileName -Encoding utf8 -Append
# モダン GUI がアクティブな場合、リアルタイムログ画面に追記 & 描画更新
if ($null -ne $script:guiTxtLog) {
try {
$formatted = $(Get-Translate($Log))
$script:guiTxtLog.Text += "`r`n$formatted"
if ($null -ne $script:guiScrollLog) {
$script:guiScrollLog.ScrollToEnd()
}
[System.Windows.Threading.Dispatcher]::CurrentDispatcher.Invoke([Action]{}, [System.Windows.Threading.DispatcherPriority]::Background)
} catch {}
}
# echo させるために出力したログを戻す
Return $(Get-Translate($Log))
}
trap [Exception] {
# イベント・ログに書き込む
Write-Log $error[0].exception
break
}
Write-Log "Running With Powershell Version $($PSVersionTable.PSVersion.Major).$($PSVersionTable.PSVersion.Minor).$($PSVersionTable.PSVersion.Patch)"
Write-Log " "
Write-Log "-----------------------------------------------------------------"
Write-Log " "
Write-Log " AmongUs Mod Deploy Script "
Write-Log " Version: $version"
Write-Log " Build : $build"
Write-Log "-----------------------------------------------------------------"
Write-Log "MOD Installation Starts"
Write-Log "-----------------------------------------------------------------"
if (!(Get-Module -Name 7Zip4Powershell -ListAvailable)) {
Install-Module -Name 7Zip4Powershell -Force -Scope CurrentUser
}
#################################################################################################
# Icon and AUMADS Folder on Desktop
#################################################################################################
if (!(Test-Path "$dsk\AUMADS.ico")) {
aria2c -x16 -s16 -j16 -V --dir "$dsk" -o "AUMADS.ico" "https://raw.githubusercontent.com/Maximilian2022/AmongUs-Mod-Auto-Deploy-Script/main/optional/AUMADS.ico" --disable-ipv6
}
if ($icorenew) {
Remove-Item "$dsk\AUMADS.ico" -Force
aria2c -x16 -s16 -j16 -V --dir "$dsk" -o "AUMADS.ico" "https://raw.githubusercontent.com/Maximilian2022/AmongUs-Mod-Auto-Deploy-Script/main/optional/AUMADS.ico" --disable-ipv6
}
if (!(Test-Path "$dsk\AUMADS.ico")) {
try {
magick.exe -help | Out-Null
}
catch {
Start-Process pwsh -ArgumentList '-NoProfile -ExecutionPolicy Bypass -WindowStyle Minimized -Command choco install -y imagemagick.app -PackageParameters "InstallDevelopmentHeaders=true LegacySupport=true"' -Verb RunAs -Wait
}
aria2c -x16 -s16 -j16 -V --dir "$dsk" -o "icon.png" "https://3dicons.sgp1.cdn.digitaloceanspaces.com/v1/dynamic/premium/rocket-dynamic-premium.png" --disable-ipv6
magick.exe convert "$dsk\icon.png" -define icon:auto-resize=16, 48, 256 -compress zip "$dsk\AUMADS.ico"
Remove-Item "$dsk\icon.png" -Force
}
#################################################################################################
# Folder用Function
#################################################################################################
#Special Thanks
#https://qiita.com/Kosen-amai/items/7b2339d7de8223ab77c4
Add-Type -AssemblyName System.Windows.Forms
function Get-FolderPathG {
param(
[Parameter(ValueFromPipeline = $true)]
[string]$Description = $(Get-Translate("フォルダを選択してください")),
[boolean]$CurrentDefault = $false
)
# メインウィンドウ取得
$process = [Diagnostics.Process]::GetCurrentProcess()
$window = New-Object Windows.Forms.NativeWindow
$window.AssignHandle($process.MainWindowHandle)
$fd = New-Object System.Windows.Forms.FolderBrowserDialog
$fd.Description = $Description
if ($CurrentDefault -eq $true) {
# カレントディレクトリを初期フォルダとする
$fd.SelectedPath = (Get-Item $PWD).FullName
}
# フォルダ選択ダイアログ表示
$ret = $fd.ShowDialog($window)
if ($ret -eq [System.Windows.Forms.DialogResult]::OK) {
return $fd.SelectedPath
}
else {
return $null
}
}
#################################################################################################
# バイト配列を16進数文字列に変換する.
#################################################################################################
function ToHex([byte[]] $hashBytes) {
$builder = New-Object System.Text.StringBuilder
$hashBytes | ForEach-Object { [void] $builder.Append($_.ToString("x2")) }
$builder.ToString()
}
#func backup
Add-Type -AssemblyName UIAutomationClient
$oldtype = $true
if (($script:platform -eq "epic" -or $DeployPlatform -eq "epic" -or $env:TARGET_PLATFORM -eq "Epic") -and ((Test-Path "C:\Program Files\Epic Games\AmongUs") -or (Test-Path "C:\Program Files\Epic Games\Among Us"))) {
$legver = legendary.exe -V
if ($legver -ge 'legendary version "0.20.29", codename "Dark Energy (hotfix #3)"') {
}
else {
Start-Process pwsh -ArgumentList "-NoProfile -ExecutionPolicy Bypass -WindowStyle Minimized -Command choco upgrade legendary -y" -Verb RunAs -Wait
#legendaryが最新じゃないので手動でDL
$rel2 = "https://api.github.com/repos/derrod/legendary/releases/latest"
$webs = Invoke-WebRequest $rel2 -UseBasicParsing
$webs2 = ConvertFrom-Json $webs.Content
$aus = $webs2.assets.browser_download_url
Write-Log $(Get-Translate("Legendary Latest DLL download start"))
if (!(Test-Path "$aupathm\BepInEx\plugins\")) {
New-Item "$aupathm\BepInEx\plugins\" -Type Directory
}
for ($aaai = 0; $aaai -lt $aus.Length; $aaai++) {
if ($($aus[$aaai]).IndexOf(".exe") -gt 0) {
aria2c -x16 -s16 -j16 -V --allow-overwrite=true --dir "$Env:ALLUSERSPROFILE\chocolatey\bin" -o "legendary.exe" $($aus[$aaai])
Write-Log "$($aus[$aaai])"
Write-Log "Legendaryのバージョンが古いため、最新に更新しました。"
}
}
if (!$BatchChild -and !$isall) {
Write-Log "重要ファイルの更新がありました。"
Write-Log "再度Batファイルを実行してください。"
Pause
Exit
}
}
}
function BackupMod {
#Backup Mod
if (!(Test-Path $aupathb)) {
New-Item $aupathb -ItemType Directory
}
if (!(Test-Path $aupathb\$scid)) {
New-Item $aupathb\$scid -ItemType Directory
}
Write-Log $(Get-Translate("Mod Backup Feature Start"))
if ($scid -ne "AMS") {
if (Test-Path "$aupathb\$scid\$scid-$torv.zip") {
$orgsize = (Get-Item "$aupathb\$scid\$scid-$torv.zip").Length
$dlfsize = (Get-Item "$aupathm\TheOtherRoles.zip").Length
if ($orgsize -lt $dlfsize) {
Copy-Item "$aupathm\TheOtherRoles.zip" "$aupathb\$scid\$scid-$torv.zip" -Force
}
}
else {
Copy-Item "$aupathm\TheOtherRoles.zip" "$aupathb\$scid\$scid-$torv.zip"
}
}
else {
if (Test-Path "$aupathb\$scid\$scid-$torv.dll") {
$orgsize = (Get-Item "$aupathb\$scid\$scid-$torv.dll").Length
$dlfsize = (Get-Item "$aupathm\BepInEx\plugins\AUModS.dll").Length
if ($orgsize -lt $dlfsize) {
Copy-Item "$aupathm\BepInEx\plugins\AUModS.dll" "$aupathb\$scid\$scid-$torv.dll" -Force
}
}
else {
Copy-Item "$aupathm\BepInEx\plugins\AUModS.dll" "$aupathb\$scid\$scid-$torv.dll" -Force
}
}
Write-Log "Mod Backup Feature End"
}
function BackUpAU {
#Backup System
if (Test-Path $aupathb) {
}
else {
New-Item $aupathb -ItemType Directory
}
Write-Log "Backup Feature Start"
#Current Ver check
$datest = Get-Date -Format "yyyyMMdd-hhmmss"
$backhashtxt = "$aupathb\backuphash.txt"
$backtracktxt = "$aupathb\backuptrack.txt"
$backuptxt = "$aupathb\backupfn.txt"
# 既存ユーザーの互換性処理: 古いハッシュファイルがあれば削除し、新しいトラック処理に移行
if (Test-Path $backhashtxt) {
Remove-Item $backhashtxt -Force
# backupfn.txt が存在する場合、バックアップZIPが存在しているはずなので、
# トラックファイルだけを現状のAmongUsフォルダから作成して次回以降のチェックに備える
if (Test-Path $backuptxt) {
$files = Get-ChildItem $aupatho -Recurse | Where-Object { !$_.PSIsContainer }
$trackData = ""
foreach ($file in $files) {
$trackData += "$($file.Name):$($file.Length):$($file.LastWriteTime.Ticks)|"
}
$trackData | Out-File $backtracktxt -Encoding utf8
}
}
# トラック情報の構築関数(高速)
function Get-FolderTrackInfo($folderPath) {
if (!(Test-Path $folderPath)) { return "" }
$trackBuilder = New-Object System.Text.StringBuilder
try {
$dirInfo = New-Object System.IO.DirectoryInfo($folderPath)
$files = $dirInfo.EnumerateFiles("*", [System.IO.SearchOption]::AllDirectories)
foreach ($file in $files) {
[void]$trackBuilder.Append("$($file.Name):$($file.Length):$($file.LastWriteTime.Ticks)|")
}
}
catch {
Write-Log "Warning: Folder track info extraction failed: $_"
}
return $trackBuilder.ToString()
}
if (test-path "$backuptxt") {
$f = (Get-Content $backuptxt) -as [string[]]
$filen = $f[0]
Write-Log $filen
$r = Get-FolderTrackInfo $aupatho
$e = ""
if (Test-Path $backtracktxt) {
$e = Get-Content $backtracktxt -Raw
}
if ($null -ne $filen -and $filen.Trim().IndexOf($amver) -lt 0) {
$e = "retake"
}
if ($r.Trim() -eq $e.Trim()) {
Write-Log "古い同一Backupが見つかったのでSkipします"
}
else {
Write-Log "新しいBackupが見つかったので生成します"
# 差分ファイルの特定とログ出力
if ($e -ne "" -and $e -ne "retake") {
$eFiles = @{}
foreach ($item in $e.Split('|')) {
if ($item -match '^(.+?):(\d+?):(\d+)$') {
$eFiles[$Matches[1]] = @{ Length = $Matches[2]; Ticks = $Matches[3] }
}
}
$rFiles = @{}
foreach ($item in $r.Split('|')) {
if ($item -match '^(.+?):(\d+?):(\d+)$') {
$rFiles[$Matches[1]] = @{ Length = $Matches[2]; Ticks = $Matches[3] }
}
}
# 差分チェック
foreach ($name in $rFiles.Keys) {
if (!$eFiles.ContainsKey($name)) {
Write-Log "差分検出: 新規ファイル -> $name"
}
else {
$eLen = [long]$eFiles[$name].Length
$rLen = [long]$rFiles[$name].Length
$eTicks = [long]$eFiles[$name].Ticks
$rTicks = [long]$rFiles[$name].Ticks
if ($eLen -ne $rLen -or $eTicks -ne $rTicks) {
Write-Log "差分検出: 変更あり -> $name (サイズ: $eLen -> $rLen, 更新日時Ticks: $eTicks -> $rTicks)"
}
}
}
foreach ($name in $eFiles.Keys) {
if (!$rFiles.ContainsKey($name)) {
Write-Log "差分検出: 削除されたファイル -> $name"
}
}
}
Write-Output $(Join-path $aupathb "Among Us-$datest-v$amver.zip") > $backuptxt
Compress-7Zip -Path $aupatho -ArchiveFileName $(Join-path $aupathb "Among Us-$datest-v$amver.zip")
if (Test-Path $backtracktxt) { Remove-Item -Path $backtracktxt -Force }
if (Test-Path $backuptxt) { Remove-Item -Path $backuptxt -Force }
$r | Out-File $backtracktxt -Encoding utf8
Write-Output $(Join-path $aupathb "Among Us-$datest-v$amver.zip") > $backuptxt
}
}
else {
Write-Log "Backupが見つかりません。生成します。"
$r = Get-FolderTrackInfo $aupatho
$r | Out-File $backtracktxt -Encoding utf8
Write-Output $(Join-path $aupathb "Among Us-$datest-v$amver.zip") > $backuptxt
Compress-7Zip -Path $aupatho -ArchiveFileName $(Join-path $aupathb "Among Us-$datest-v$amver.zip")
}
#Manifest Backup
if ($platform -eq "epic") {
if (!(Test-Path "$aupathb\epic_manifest")) {
New-Item "$aupathb\epic_manifest" -Type Directory
}
if (Test-Path "$aupatho\.egstore") {
if (!(Test-Path "$aupathb\$amver.manifest")) {
$egmani = Get-ChildItem -path "$aupatho\.egstore\*.manifest"
Copy-Item "$aupatho\.egstore\$($egmani[0].Name)" "$aupathb\epic_manifest\v$amver.manifest"
}
}
}
#Previous ver check
$items = Get-ChildItem $aupathb -File
$prevchk = $true
foreach ($item in $items) {
if (($item.Name).IndexOf("$prever") -gt 0 ) {
$prevchk = $false
}
}
if ($prevchk) {
if ($platform -eq "steam") {
$steampth = "C:\Program Files (x86)\Steam\Steam.exe"
$steamProc = Get-Process -Name "steam" -ErrorAction SilentlyContinue | Select-Object -First 1
if (Test-Path $steampth) {
Write-Log "Steam アプリは以下で見つかりました。 $steampth"
}
elseif ($null -ne $steamProc -and (Test-Path $($steamProc.Path))) {
$steampth = $($steamProc.Path)
Write-Log "Steam アプリは以下で見つかりました。 $steampth"
}
else {
Write-Log "Steam アプリがデフォルトの場所に見つかりませんでした。"
# $FilePath が設定されていない、又はファイルが存在しない
if ([string]::IsNullOrEmpty($steampth) -Or (Test-Path -LiteralPath $steampth -PathType Leaf) -eq $false) {
[void][System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms")
$dialog = New-Object System.Windows.Forms.OpenFileDialog
$dialog.Filter = $(Get-Translate("EXE ファイル(*.EXE)|*.EXE"))
$dialog.InitialDirectory = "C:\"
$dialog.Title = $(Get-Translate("Steam.exe ファイルを選択してください"))
# キャンセルを押された時は処理を止める
if ($dialog.ShowDialog() -ne [System.Windows.Forms.DialogResult]::OK) {
exit 1
}
# 選択したファイルパスを $FilePath に設定
$steampth = $dialog.FileName
}
}
#操作したいウィンドウのタイトル
$MAIN_WINDOW_TITLE = "Steam"
#Get-Processで取得できた1つ目のハンドルを対象とする。
$steamruncheck = $true
$steamrunner = $true
while ($steamruncheck) {
try {
$hwnd = (Get-Process | Where-Object { $_.MainWindowTitle -like $MAIN_WINDOW_TITLE })[0].MainWindowHandle
}
catch {
Write-Log "Steam.exe 起動チェック。ログインできていない場合はログインしてください。"
}
if ($null -eq $hwnd) {
if ($steamrunner) {
Start-Process $steampth
$steamrunner = $false
}
}
else {
$steamruncheck = $false
}
Start-Sleep -Seconds 5
}
Start-Sleep -Seconds 2
#Among Us app id 945360
#main depot id 945361
Start-Process $steampth -argument "+download_depot 945360 945361 $prevtargetid"
Start-Sleep -Seconds 2
#ハンドルからウィンドウを取得する
$window = [System.Windows.Automation.AutomationElement]::FromHandle($hwnd)
$windowPattern = $window.GetCurrentPattern([System.Windows.Automation.WindowPattern]::Pattern)
#ウィンドウサイズを最小化する
$windowPattern.SetWindowVisualState([System.Windows.Automation.WindowVisualState]::Minimized)
Start-Sleep -Seconds 2
$stfolder = Split-Path $steampth -Parent
$bupfolder = Join-Path $stfolder "steamapps\content\app_945360\depot_945361"
$delfoldser = Join-Path $stfolder "steamapps\content\app_945360"
$counter = 0;
while (!(Test-Path $bupfolder)) {
Start-Sleep -Seconds 2
}
Write-Log "Steam.exe は前バージョン($prever)をダウンロード中です。しばらくお待ちください。(Max20分でタイムアウトします)#0"
$presu = $false
while (((Get-ChildItem $bupfolder | Measure-Object).Count) -ne 8) {
Start-sleep -Seconds 15
#timeout 10min.
if ($counter -lt 80) {
$counter++
Write-Log "Steam.exe は前バージョン($prever)をダウンロード中です。しばらくお待ちください。#$counter $((Get-ChildItem $bupfolder | Measure-Object).Count)/8"
$presu = $true
}
else {
break
Write-Log "Steam.exe の前バージョン($prever)をダウンロードがタイムアウトしました。再度お試しください。$((Get-ChildItem $bupfolder | Measure-Object).Count)/8"
}
}
if ($presu) {
Compress-7Zip -Path $bupfolder -ArchiveFileName $(Join-path $aupathb "Among Us-$datest-v$prever.zip")
Start-Sleep -Seconds 2
Remove-Item -Path $delfoldser -Recurse -Force
}
else {
Write-Log "前バージョン($prever)のロードに失敗しました。再度お試しください。"
}
}
elseif ($platform -eq "epic") {
if ($oldtype) {
$epicmanifestchk = $true
if (Test-Path "$aupathb\epic_manifest") {
$eitems = Get-ChildItem "$aupathb\epic_manifest" -File
foreach ($item in $eitems) {
if (($item.Name).IndexOf("$prever") -gt 0 ) {
$epicmanifestchk = $false
$epicmanifestfile = "$aupathb\epic_manifest\$prever.manifest"
}
}
}
if ($epicmanifestchk) {
#manifestがないから指定してもらう
Write-Log "Epic Game の過去のManifestファイルが見つかりません。Manifestファイルを指定してください。"
Add-Type -assemblyName System.Windows.Forms
$dialog = New-Object System.Windows.Forms.OpenFileDialog
$dialog.Filter = $(Get-Translate("manifest ファイル(*.manifest)|*.manifest"))
$dialog.InitialDirectory = [Environment]::GetFolderPath('Desktop')
$dialog.Title = $(Get-Translate("Manifestファイルを選択してください"))
if ($dialog.ShowDialog() -eq "OK") {
$epicmanifestfile = $dialog.FileName
}
else {
Write-Log "ファイルを選択しませんでした"
}
}
Write-Log "選択: $epicmanifestfile"
if (!(Test-Path "$aupathb\epic_manifest")) {
New-Item "$aupathb\epic_manifest" -Type Directory
}
$mfileName = Split-Path $epicmanifestfile -Leaf
Copy-Item $epicmanifestfile "$aupathb\epic_manifest\$mfilename"
$epicmanifestfile = "$aupathb\epic_manifest\$mfilename"
Write-Log "コピー: $epicmanifestfile"
#legendary でAmongusを落とす
legendary.exe auth --delete
Start-Sleep -Seconds 3
legendary.exe auth --import
legendary.exe -y import 'Among Us' "$aupatho"
legendary.exe uninstall "Among Us" --keep-files -y
Copy-Item $aupatho "$aupathb\AmongUs" -Recurse
legendary.exe -y import 'Among Us' "$aupathb\AmongUs"
Start-Sleep -Seconds 1
if (Test-Path "$aupathb\AmongUs") {
Remove-item "$aupathb\AmongUs" -Recurse -Force
legendary.exe install "Among Us" --old-manifest "$epicmanifestfile" --disable-patching --enable-reordering --repair -y
}
else {
Write-Log "何かがおかしい・・・"
}
$ptt = [System.IO.File]::ReadAllBytes("$aupathb\AmongUs\Among Us_Data\globalgamemanagers")
$ptt2 = [System.Text.Encoding]::UTF8.GetString($ptt)
$ptt3 = [regex]::Matches($ptt2, "(19|20)[0-9]{2}[- /.]([1-9]|0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])")
if ($null -eq $ptt3[1]) {
$pmver = $ptt3[0].Value
}
else {
$pmver = $ptt3[1].Value
}
if ($pmver -eq $prever) {
#success
Write-Log $(Get-Translate("Download 成功"))
Compress-7Zip -Path "$aupathb\AmongUs" -ArchiveFileName $(Join-path $aupathb "Among Us-$datest-v$prever.zip")
if (!(Test-Path "$aupathb\epic_manifest")) {
New-Item "$aupathb\epic_manifest" -Type Directory
}
if (($epicmanifestchk) -and ($epicmanifestfile -eq "$aupathb\epic_manifest\v$prever.manifest")) {
}
else {
Copy-Item $epicmanifestfile "$aupathb\epic_manifest\v$prever.manifest"
Remove-Item $epicmanifestfile -Force
}
}
else {
Write-Log "Download 失敗か、指定されたManifestが選択されたバージョンではありませんでした"
Write-Log "指定したManifestを確認するか、再度やり直してください"
Remove-Item $epicmanifestfile -Force
Pause
Exit
}
if (Test-Path "$aupathb\AmongUs") {
Remove-item "$aupathb\AmongUs" -Recurse -Force
}
}
}
}
Write-Log "Backup Feature Ends"
}
#################################################################################################
### Convertfrom-vdf
### Ref. from https://github.com/ChiefIntegrator/Steam-GetOnTop
#################################################################################################
Function ConvertFrom-VDF {
param
(
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.String[]]$InputObject
)
process {
$root = New-Object -TypeName PSObject
$chain = [ordered]@{}
$depth = 0
$parent = $root
$element = $null
ForEach ($line in $InputObject) {
$quotedElements = (Select-String -Pattern '(?<=")([^\"\t\s]+\s?)+(?=")' -InputObject $line -AllMatches).Matches
if ($quotedElements.Count -eq 1) {
# Create a new (sub) object
$element = New-Object -TypeName PSObject
Add-Member -InputObject $parent -MemberType NoteProperty -Name $quotedElements[0].Value -Value $element
}
elseif ($quotedElements.Count -eq 2) {
# Create a new String hash
Add-Member -InputObject $element -MemberType NoteProperty -Name $quotedElements[0].Value -Value $quotedElements[1].Value
}
elseif ($line -match "{") {
$chain.Add($depth, $element)
$depth++
$parent = $chain.($depth - 1) # AKA $element
}
elseif ($line -match "}") {
$depth--
$parent = $chain.($depth - 1)
$element = $parent
$chain.Remove($depth)
}
else {
# Comments etc
}
}
return $root
}
}
#################################################################################################
### 高速Download
#################################################################################################
if (!(Test-Path "C:\Temp")) {
New-Item "C:\Temp" -Type Directory
}
try {
aria2c -v | Out-Null
}
catch {
try {
choco -v
}
catch {
Start-Process powershell -ArgumentList "-Command Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))" -Verb RunAs -Wait
}
Start-Process pwsh -ArgumentList "-NoProfile -ExecutionPolicy Bypass -WindowStyle Minimized -Command choco upgrade aria2 legendary microsoft-windows-terminal -y" -Verb RunAs -Wait
}
#################################################################################################
# Clock Sync (Async)
#################################################################################################
$w32tmJob = [powershell]::Create().AddScript({
try {
$l = w32tm /query /status
if ($l.contains("0x80070426")) {
Start-Process pwsh -ArgumentList "-NoProfile -ExecutionPolicy Unrestricted -WindowStyle Minimized -Command 'net start `"windows time`" ;start-sleep -Seconds 5; w32tm /monitor /computers:time.google.com;w32tm /config /syncfromflags:manual /manualpeerlist:`"time.google.com,0x8 time.aws.com,0x8 time.cloudflare.com,0x8`" /reliable:yes /update;w32tm /resync;w32tm /query /status'" -Verb RunAs
}
else {
Start-Process pwsh -ArgumentList "-NoProfile -ExecutionPolicy Unrestricted -WindowStyle Minimized -Command 'w32tm /monitor /computers:time.google.com;w32tm /config /syncfromflags:manual /manualpeerlist:`"time.google.com,0x8 time.aws.com,0x8 time.cloudflare.com,0x8`" /reliable:yes /update;w32tm /resync;w32tm /query /status'" -Verb RunAs
}
}
catch {
# Ignore errors quietly in the background
}
})
[void]$w32tmJob.BeginInvoke()
$platform = ""
$scid = "TOR GMH"
$tio = $true
$aumin = ""
$aumax = "NONE"
$aupatho = ""
$aupathm = ""
$aupathb = ""
$releasepage = ""
$ovwrite = $false
$amver = ""
$prebool = $false
$latestflag = 0
$isall = $false
$opflag = $false
$ym = Get-Date -Format yyyyMM
#################################################################################################
# Steam 版 Among Us 配置待機 & ダウンロード進捗監視・フェイルセーフ関数
#################################################################################################
function Wait-ForSteamAmongUsInstall([string]$aupath, [int]$timeoutSec = 600) {
$elapsed = 0
$lastDownloaded = -1
$stallCount = 0
$restartedSteam = $false
$acfPath = "C:\Program Files (x86)\Steam\steamapps\appmanifest_945360.acf"
$steampth = "C:\Program Files (x86)\Steam\Steam.exe"
if (Test-Path "HKCU:\Software\Valve\Steam") {
$regExe = (Get-ItemProperty -Path "HKCU:\Software\Valve\Steam" -Name "SteamExe" -ErrorAction SilentlyContinue).SteamExe
if ($regExe -and (Test-Path $regExe)) { $steampth = $regExe.Replace('/', '\') }
}