boss911
Silver Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору Запуск батником. Код: for %%f in (disallowedcert.sst, authroots.sst, delroots.sst, roots.sst, updroots.sst) do ( cscript //NoLogo //t:15 script.vbs "http://www.download.windowsupdate.com/msdownload/update/v3/static/trustedr/en/%%f" "%~dp0" ) | Код: ' Usage If WScript.Arguments.Count < 1 Then WScript.Echo "Usage: wget.vbs <url> (path (with filename))" WScript.Quit End If ' Arguments strUrl = WScript.Arguments(0) If WScript.Arguments.Count > 1 Then strPath = WScript.Arguments(1) Else parts = Split(strUrl, "/") strPath = ".\" & parts(Ubound(parts)) End if ' Check if the specified target file or folder exists, ' and build the fully qualified path of the target file Set objFSO = CreateObject("Scripting.FileSystemObject") If objFSO.FolderExists(strPath) Then strFile = objFSO.BuildPath(strPath, Mid(strUrl, InStrRev(strUrl, "/") + 1)) ElseIf objFSO.FolderExists(Left(strPath, InStrRev(strPath, "\") - 1)) Then strFile = strPath Else WScript.Echo "ERROR: Target folder not found" WScript.Quit End If ' Download Set objHttp = CreateObject("WinHttp.WinHttpRequest.5.1") ' objHttp.Option(4) = 0x3300; ' SslErrorIgnoreFlags objHttp.Open "GET", strUrl, False objHttp.Send lmdate = objHttp.GetResponseHeader("Last-Modified") ' WScript.Echo "INFO: 'lmdate': " & lmdate ' WScript.Echo "INFO: 'cdate': " & Join(Slice(Split(lmdate), 1, 3)) & " " & Join(Slice(Split(lmdate), 4, 4)) objDate = CDate(Join(Slice(Split(lmdate), 1, 3)) & " " & Join(Slice(Split(lmdate), 4, 4))) ' WScript.Echo "INFO: 'cdate': " & FormatDateTime( objDate ) Function Slice (aInput, Byval aStart, Byval aEnd) If IsArray(aInput) Then Dim i Dim intStep Dim arrReturn If aStart < 0 Then aStart = aStart + Ubound(aInput) + 1 End If If aEnd < 0 Then aEnd = aEnd + Ubound(aInput) + 1 End If Redim arrReturn(Abs(aStart - aEnd)) If aStart > aEnd Then intStep = -1 Else intStep = 1 End If For i = aStart To aEnd Step intStep If Isobject(aInput(i)) Then Set arrReturn(Abs(i-aStart)) = aInput(i) Else arrReturn(Abs(i-aStart)) = aInput(i) End If Next Slice = arrReturn Else Slice = Null End If End Function Function setDate (strFile) Set fso = CreateObject("Scripting.FileSystemObject") fileDir = fso.GetParentFolderName(strFile) strFile = fso.GetFileName(strFile) ' WScript.Echo "INFO: 'fileDir': " & fileDir ' WScript.Echo "INFO: 'strFile': " & strFile ' WScript.Echo "INFO: 'objDate': " & objDate Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.NameSpace(fileDir) Set objFolderItem = objFolder.ParseName(strFile) objFolderItem.ModifyDate = objDate End Function ' Save If objHttp.Status = 200 Then Set objStream = CreateObject("ADODB.Stream") objStream.Type = 1 ' binary objStream.Open objStream.Write objHttp.ResponseBody objStream.SaveToFile strFile, 2 ' overwrite objStream.Close ' if (not objDate is nothing) then setDate(strFile) ' End if Else WScript.Echo "ERROR: Downloading failed with status " & objHttp.StatusText End If |
|