zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    为django项目创建虚拟环境
    linux下安装python
    使用scrapy-crawlSpider 爬取tencent 招聘
    linux基础3
    Scrapy
    scrapy-Redis 分布式爬虫
    scrapy-redis(一)
    Linux中文件上传使用rz
    centos 7 安装nginx
    MySQL 5.7 zip 文件安装过程
  • 原文地址:https://www.cnblogs.com/cnhack/p/15019642.html
Copyright © 2011-2022 走看看