-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaumod-cleaner.vbs
126 lines (107 loc) · 3.51 KB
/
aumod-cleaner.vbs
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
Option Explicit
'--- configs
Const enableUacCtl = True
Const steamRegEntry32 = "HKLM\SOFTWARE\Valve\Steam\InstallPath"
Const steamRegEntry64 = "HKLM\SOFTWARE\Wow6432Node\Valve\Steam\InstallPath"
Const auRegEntry = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 945360\InstallLocation"
'--- codes
Dim oShell : Set oShell = WScript.CreateObject("Wscript.Shell")
Dim oFso : Set oFso = WScript.CreateObject("Scripting.FileSystemObject")
Sub removeDirectory(path)
Call oFso.DeleteFolder(path, True)
End Sub
Sub removeFile(path)
Call oFso.DeleteFile(path, True)
End Sub
Sub remove(path)
Dim removeSub : removeSub = Null
If oFso.FolderExists(path) Then
Set removeSub = GetRef("removeDirectory")
ElseIf oFso.FileExists(path) Then
Set removeSub = GetRef("removeFile")
End If
If Not IsNull(removeSub) Then
WScript.Echo """" & path & """ を削除しています"
Call removeSub(path)
End If
End Sub
Sub cleanModEnvironments(auDir)
Call remove(auDir & "\BepInEx")
Call remove(auDir & "\mono")
Call remove(auDir & "\winhttp.dll")
Call remove(auDir & "\doorstop_config.ini")
Call remove(auDir & "\steam_appid.txt")
End Sub
Function getAuDir()
Dim auDir
getAuDir = ""
On Error Resume Next
auDir = oShell.RegRead(auRegEntry)
If Err.Number = 0 Then
getAuDir = auDir
End If
Err.Clear
On Error Goto 0
End Function
Function isSteamInstalled()
isSteamInstalled = True
On Error Resume Next
oShell.RegRead steamRegEntry64
If Err.Number <> 0 Then
Err.Clear : oShell.RegRead steamRegEntry32
If Err.Number <> 0 Then
WScript.Echo "Steam がインストールされていません"
isSteamInstalled = False
End If
End If
Err.Clear
On Error Goto 0
End Function
Function main()
Dim auDir
Dim retMsg
WScript.Echo "Among Us Mod Cleaner (Steam)"
WScript.Echo ""
If Not isSteamInstalled Then
main = 1 : Exit Function
End If
auDir = getAuDir
If auDir = "" Then
main = 1 : Exit Function
End If
WScript.Echo "Among Us Dir: """ & auDir & """"
retMsg = MsgBox("Among Us のMod環境をおそうじしてもよいですか?", vbYesNo Or vbQuestion Or vbDefaultButton2)
If retMsg = vbNo Then
WScript.Echo "Mod環境のおそうじはキャンセルされました"
main = 0 : Exit Function
End If
WScript.Echo ""
Call cleanModEnvironments(auDir)
WScript.Echo "おそうじ完了"
main = 0
End Function
'--- entry point
' UAC (https://www.server-world.info/query?os=Other&p=vbs&f=1)
If enableUacCtl Then
Do While WScript.Arguments.Count = 0 and WScript.Version >= 5.7
Dim Wmi : Set Wmi = GetObject("winmgmts:\\.\root\CIMV2")
Dim OS, Value
'##### Check if it is WScript 5.7 or Vista or later
Set OS = Wmi.ExecQuery("SELECT *FROM Win32_OperatingSystem")
For Each Value in OS
If left(Value.Version, 3) < 6.0 Then Exit Do
Next
'##### Run as administrator.
WScript.Quit WScript.CreateObject("Shell.Application").ShellExecute("cmd.exe", " /k cscript.exe /nologo """ & WScript.ScriptFullName & """ uac", "", "runas")
Loop
End If
If LCase(Right(WScript.FullName, 11)) = "wscript.exe" Then
Dim args : args = Array("cmd.exe /k cscript.exe /nologo",""""&WScript.ScriptFullName&"""")
Dim arg
For Each arg In WScript.Arguments
ReDim Preserve args(UBound(args)+1)
args(UBound(args)) = """" & arg & """"
Next
WScript.Quit CreateObject("WScript.Shell").Run(Join(args), 1, True)
End If
WScript.Quit main