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


    '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
    
    

    本文来自博客园,作者:晴云孤魂,转载请注明原文链接:https://www.cnblogs.com/cnhack/p/15019642.html

  • 相关阅读:
    同步 异步 阻塞 非阻塞深入理解
    TCP的三次握手四次挥手
    dom事件
    Vue 无痕 刷新页面
    事件冒泡 捕获 事件流
    gulp
    懒加载
    Object.prototype.toString.call() 判断某个对象属于哪种内置类型 type instanceof Object.prototype.toString.call 区别
    css sass less
    node module.exports exports
  • 原文地址:https://www.cnblogs.com/cnhack/p/15019642.html
Copyright © 2020-2023  润新知