首页 > Windows开发 > 详细

VBS检查Cygwin安装器setup-x86_64.exe是否有更新

时间:2021-07-16 15:41:06      阅读:29      评论:0      收藏:0      [点我收藏+]
‘CreateObject("Shell.Application").ShellExecute "http://www.cygwin.com/setup-x86_64.exe"

Dim Etag,ExeUrl
ExeUrl="http://www.cygwin.com/setup-x86_64.exe"
Set http=CreateObject("Msxml2.XMLHTTP")
http.open "GET",ExeUrl,false
http.send
Etag=http.getResponseHeader("Etag")
ConfigEtag=GetConfigEtag()
If Etag=ConfigEtag Then
    Msgbox "setup-x86_64.exe 暂无可用更新....",64,"提示"
Else
    confirmUpdate=Msgbox("有可用更新,是否现在更新?",vbyesno+vbquestion,"是否更新")
    If confirmUpdate=7 Then Wscript.Quit
    download ExeUrl,"setup-x86_64_newer.exe"
    Msgbox "Download Complate!",64,"下载完成"
    Call WriteEtag(Etag)
    Call RenameFiles()
End IF



Function GetConfigEtag()
    Set fso=Createobject("scripting.filesystemobject")
    set file=fso.opentextfile("cygwin-setup-etag.txt",1)
    configEtag=file.ReadLine()
    file.close()
    GetConfigEtag = configEtag
    Set file = nothing
    Set fso = nothing
End Function


Sub download(url,target)
	Const adTypeBinary = 1
	Const adSaveCreateOverWrite = 2
	Dim http,ado
	Set http = CreateObject("Msxml2.XMLHTTP")
	http.open "GET",url,False
	http.send
	Set ado = createobject("Adodb.Stream")
	ado.Type = adTypeBinary
	ado.Open
	ado.Write http.responseBody
	ado.SaveToFile target
	ado.Close
End Sub


Sub WriteEtag(Etag)
    Set fso=Createobject("scripting.filesystemobject")
    set file=fso.opentextfile("cygwin-setup-etag.txt",2)
    File.Write Etag
    file.close()
End Sub


Sub RenameFiles()
	Set fso=CreateObject("scripting.filesystemobject")
	fso.MoveFile "setup-x86_64.exe","setup-x86_64_old.exe"
	fso.MoveFile "setup-x86_64_newer.exe","setup-x86_64.exe"
	Set fso = nothing
End Sub

VBS检查Cygwin安装器setup-x86_64.exe是否有更新

原文:https://www.cnblogs.com/cnhack/p/15019642.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!