1 Star 1 Fork 1

CKF3 / CKF3patch

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
CKF3Updater.vbs 6.54 KB
一键复制 编辑 原始数据 按行查看 历史
elite_stay 提交于 2015-06-08 01:02 . 2015.6.8
forceCScriptExecution
SetLocale(1033)
dim oShell, appDataLocation
Set oShell = CreateObject( "WScript.Shell" )
appDataLocation=oShell.ExpandEnvironmentStrings("%APPDATA%")
dim path
path = oShell.CurrentDirectory
'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", "http://git.oschina.net/CKF3/CKF3patch/raw/master/CKF3version.txt", False
xHttp.Send
dim latestVer, currentVer, latestVerStr, currentVerStr
latestVerStr = xHttp.responseText
latestVer = CDbl(xHttp.responseText)
currentVer = 0.00
If (latestVer < 1) Then
Wscript.echo "更新服务器维护中,暂时无法更新......"
GoSleep(2)
Wscript.quit(0)
End If
dim verFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
If (objFSO.FileExists(appDataLocation & "\CKF3version.txt")) Then
Set verFile = objFSO.OpenTextFile(appDataLocation & "\CKF3version.txt",1)
currentVerStr = verFile.ReadAll()
If (InStr(currentVerStr, ".") > 0) Then
currentVer = CDbl(currentVerStr)
End If
verFile.Close
Set verFile = Nothing
End If
Wscript.echo "最新版本: " & latestVer & " -- 当前版本: " & currentVer
If (currentVer >= latestVer) Then
Wscript.echo "你的客户端已经是最新版本了,不需要更新"
GoSleep(2)
Wscript.quit(0)
End If
Wscript.echo "你的客户端可以更新,正在下载最新版本,请稍候..."
Set xHttp = createobject("MSXML2.ServerXMLHTTP.6.0")
Set bStrm1 = createobject("Adodb.Stream")
Set bStrm2 = createobject("Adodb.Stream")
'xHttp.Open "GET", "https://github.com/GetDotaStats/GetDotaLobby/raw/lobbybrowser/play_weekend_tourney.zip", False
xHttp.Open "GET", "http://git.oschina.net/CKF3/CKF3patch/raw/master/CKF3patch.zip", False
'xHttp.Open "GET", "https://s3.amazonaws.com/gdslx/play_weekend_tourney.zip", False
xHttp.Send
with bStrm1
.type = 1 '//binary
.open
.write xHttp.responseBody
.savetofile appDataLocation & "\sb.zip", 2 '//overwrite
end with
'xHttp.Open "GET", "https://github.com/GetDotaStats/GetDotaLobby/raw/lobbybrowser/play_weekend_tourney.zip", False
xHttp.Open "GET", "http://git.oschina.net/CKF3/CKF3patch/raw/master/ckf3.exe", False
'xHttp.Open "GET", "https://s3.amazonaws.com/gdslx/play_weekend_tourney.zip", False
xHttp.Send
with bStrm2
.type = 1 '//binary
.open
.write xHttp.responseBody
.savetofile appDataLocation & "\ckf3.exe", 2 '//overwrite
end with
Wscript.echo "下载完成"
dim found
found = False
if path <> "" then
if objFSO.FolderExists(path & "\cstrike\") then
found = True
Wscript.echo "安装到: " & path & "\ckf3"
Wscript.echo "正在安装..."
Dim objShell
Set objShell = WScript.CreateObject ("WScript.shell")
objShell.run "cmd /c mkdir """ & path & "\ckf3""", 7, true
'objShell.run "xcopy resource """ & path & "\steamapps\common\dota 2 beta\dota\resource""" & " /Y /E ", 7, true
Set objShell = Nothing
UnzipFiles objFSO.GetAbsolutePathName(path & "\ckf3"), objFSO.GetAbsolutePathName(appDataLocation & "\sb.zip")
if objFSO.FileExists(path & "\ckf3.exe") then
objFSO.DeleteFile(path & "\ckf3.exe")
end if
objFSO.MoveFile appDataLocation & "\ckf3.exe", path & "\ckf3.exe"
end if
end if
if found then
Wscript.echo "安装完成"
else
Wscript.echo "无法获取ckf3目录,安装失败"
GoSleep(3)
wscript.quit(0)
end if
' Write out the version.txt since the update suceeded
Set verFile = objFSO.OpenTextFile(appDataLocation & "\CKF3version.txt",2,true)
verFile.WriteLine(latestVerStr)
verFile.Close
Set verFile = Nothing
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
'========================
'Sub: UnzipFiles
'Language: vbscript
'Usage: UnzipFiles("C:\dir", "extract.zip")
'Definition: UnzipFiles([Directory where zip is located & where files will be extracted], [zip file name])
'========================
Sub UnzipFiles(folder, file)
Dim sa, filesInzip, zfile, fso, i : i = 1
Set sa = CreateObject("Shell.Application")
Set fso = CreateObject("Scripting.FileSystemObject")
'WScript.echo folder
'WScript.echo file
Set filesInzip=sa.NameSpace(file).Items()
For Each zfile In filesInzip
IF fso.FileExists(folder & zfile) Then
fso.DeleteFile(folder & zfile)
End If
If Not fso.FileExists(folder & zfile) Then
sa.NameSpace(folder).CopyHere zfile, 20
i = i + 1
End If
If i = 99 Then
zCleanup file, i
i = 1
End If
Next
If i > 1 Then
zCleanup file, i
End If
'fso.DeleteFile(folder&file)
End Sub
'========================
'Sub: zCleanup
'Language: vbscript
'Usage: zCleanup("filename.zip", 4)
'Definition: zCleanup([Filename of Zip previously extracted], [Number of files within zip container])
'========================
Sub zCleanUp(file, count)
'Clean up
Dim i, fso
Set fso = CreateObject("Scripting.FileSystemObject")
For i = 1 To count
If fso.FolderExists(fso.GetSpecialFolder(2) & "\Temporary Directory " & i & " for " & file) = True Then
text = fso.DeleteFolder(fso.GetSpecialFolder(2) & "\Temporary Directory " & i & " for " & file, True)
Else
Exit For
End If
Next
End Sub
Visual Basic
1
https://gitee.com/CKF3/CKF3patch.git
git@gitee.com:CKF3/CKF3patch.git
CKF3
CKF3patch
CKF3patch
master

搜索帮助