-
Notifications
You must be signed in to change notification settings - Fork 2
/
LXUninstaller.vbs
157 lines (123 loc) · 4 KB
/
LXUninstaller.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
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
forceCScriptExecution
dim boxresult
boxresult = MsgBox ("Are you sure you want to uninstall the Lobby Explorer? This will delete any local settings you have.", vbYesNo, "Uninstall Lobby Explorer?")
Select Case boxresult
Case vbNo
wscript.quit(0)
End Select
SetLocale(1033)
dim steampath
dim steampaths(20)
steampath = readfromRegistry("HKEY_CURRENT_USER\Software\Valve\Steam\SteamPath", "")
dim oShell, appDataLocation
Set oShell = CreateObject( "WScript.Shell" )
appDataLocation=oShell.ExpandEnvironmentStrings("%APPDATA%")
dim count
count = 0
steampaths(count) = steampath
count = count + 1
if steampath = "" then
wscript.echo "Failed to find the steam directory. If you're sure steam is installed, follow the manual installation."
GoSleep(3)
wscript.quit(1)
end if
'dim xHttp: Set xHttp = createobject("Microsoft.XMLHTTP")
dim xHttp: Set xHttp = createobject("MSXML2.ServerXMLHTTP.6.0")
dim bStrm: Set bStrm = createobject("Adodb.Stream")
'xHttp.Open "GET", "http://getdotastats.com/d2mods/api/lobby_version.txt", False
xHttp.Open "GET", "https://github.com/GetDotaStats/GetDotaLobby/raw/master/version.txt", False
xHttp.Send
dim latestVer, currentVer, latestVerStr, currentVerStr
latestVerStr = xHttp.responseText
latestVer = CDbl(xHttp.responseText)
currentVer = 0.00
dim verFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
If (objFSO.FileExists(appDataLocation & "\version.txt")) Then
objFSO.DeleteFile(appDataLocation & "\version.txt")
Wscript.echo "Deleted old version.txt"
End If
If (objFSO.FileExists(appDataLocation & "\lx.zip")) Then
objFSO.DeleteFile(appDataLocation & "\lx.zip")
Wscript.echo "Deleted lx.zip"
End If
Set objFile = objFSO.OpenTextFile(steampath & "\config\config.vdf", 1)
dim line
Set myRegExp = New RegExp
myRegExp.IgnoreCase = True
myRegExp.Global = True
myRegExp.Pattern = """BaseInstallFolder_.+""[^""]+""(.*)"""
i = 0
Do Until objFile.AtEndOfStream
line = objFile.ReadLine
if InStr(line, """BaseInstallFolder_") <> 0 then
Set mc = myRegExp.Execute(line)
if mc.Count = 0 then
wscript.echo "Couldn't find steam base install path in config.vdf"
else
Set match = mc.Item(0)
steampaths(count) = match.SubMatches.Item(0)
count = count + 1
end if
end if
i = i + 1
Loop
objFile.Close
dim found
found = False
Wscript.echo "UNINSTALLING LOBBY EXPLORER"
For each path In steampaths
if path <> "" then
if objFSO.FolderExists(path & "\steamapps\common\dota 2 beta\dota\resource\flash3") then
found = True
Wscript.echo "Uninstalling from path: " & path & "\steamapps\common\dota 2 beta\dota\resource\flash3"
objFSO.DeleteFolder(path & "\steamapps\common\dota 2 beta\dota\resource\flash3")
end if
end if
Next
if found then
Wscript.echo "DONE UNINSTALLING "
else
Wscript.echo "Unable to find dota directory. Uninstallation failed."
end if
GoSleep(2)
wscript.quit(0)
Function GoSleep(seconds)
wsv = WScript.Version
if wsv >= "5.1" then
WScript.Sleep(seconds * 1000)
else
startTime = Time() ' gets the current time
endTime = TimeValue(startTime) + TimeValue(elapsed) ' calculates when time is up
While endTime > Time()
DoEvents
Wend
end if
End Function
Sub forceCScriptExecution
Dim Arg, Str
If Not LCase( Right( WScript.FullName, 12 ) ) = "\cscript.exe" Then
For Each Arg In WScript.Arguments
If InStr( Arg, " " ) Then Arg = """" & Arg & """"
Str = Str & " " & Arg
Next
CreateObject( "WScript.Shell" ).Run _
"cmd /C cscript //nologo """ & _
WScript.ScriptFullName & _
""" " & Str & " && pause"
'CreateObject( "WScript.Shell" ).Run "cmd /C pause"
WScript.Quit
End If
End Sub
function readFromRegistry (strRegistryKey, strDefault )
Dim WSHShell, value
On Error Resume Next
Set WSHShell = CreateObject("WScript.Shell")
value = WSHShell.RegRead( strRegistryKey )
if err.number <> 0 then
readFromRegistry= strDefault
else
readFromRegistry=value
end if
set WSHShell = nothing
end function