Страница: 1 | 
		
		
			
	
		 
		
			
  
    |   | 
    
Вопрос: Помощь в сохранении файла
     | 
    
Добавлено: 24.08.11 16:45
     | 
      | 
  
		
			
			  
    
      
Автор вопроса:   Олег
       | 
    
    
      
Мужики.
 
Проблема (собственно и задача).
 
Есть 6 файлов, которые хранятся на сервере.
 
Но так, что зайти на сервер и как файлы я их посмотреть не могу.
 
А если ввожу http://********/cdp/garant.crl, то выводится окошко, в котором предлагается открыть или сохранить этот файл!
 
Задача состоит в том, что проверить срок действия сертификатов и их доступность.
 
Всего 6 ссылок.
 
 
Какой командой в VBS можно это описать, чтобы он хотя бы мне на комп их сохранил, а дальше я бы сам парился с командой CERTUTIL. (Не знаю как, но погуглю)
 
 
________________________________________________________
 
 
У меня windows 7. Есть ли варианты использовать команды internetexplorer.application для поставленной задачи?
 
 
Код:
 
 
Set objIE = CreateObject("InternetExplorer.Application")
 
objIE.Navigate "http://*******/cdp/garant.crl"
 
While objIE.Busy
 
 Wscript.Sleep 50
 
Wend
 
objIE.Visible = 1
 
'objIE.ExecWB 4, 2 'сохранение
 
 
 
 
Выдает ошибку в третьей строке, (но все равно перед этим выполняет открытие сертификата с сервера) так как после открытия .crl автоматически закрывается браузер и уже код ссылается на закрытый objIE.
 
 
Как сохранить crl?
 
Может сразу в файл при помощи certutil?
Ответить
        | 
    
  
		
			
		
		
			
		
	  
	  
	  
	  
    
      
Номер ответа: 4 Автор ответа:
   Олег
  
           
  Вопросов: 4 Ответов: 10 
       | 
      
 Профиль |  | #4
       | 
Добавлено:  06.09.11 12:37
       | 
    
    
      
Мужики.
 
Разобрался с друзьями.
 
Вот код.
 
 
На скачивание файла + обработку в txt + поиск по тексту + плюс перевод в дату + отсыл на почту.
 
 
- strFileURL = "http://********/garant.crl"
  
- URL = Split(StrReverse(strFileURL), "/")
  
- basename = "GE" & StrReverse(URL(0))
  
-  
 
- strHDLocation = "C:\scriptcheckcrl\" & basename
  
- Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
  
- objXMLHTTP.open "GET", strFileURL, false
  
- objXMLHTTP.send()
  
-  
 
- If objXMLHTTP.Status = 200 Then
  
-  Set objADOStream = CreateObject("ADODB.Stream")
  
-  objADOStream.Open
  
-  objADOStream.Type = 1 
 
-  objADOStream.Write objXMLHTTP.ResponseBody
  
-  objADOStream.Position = 0 
 
-  Set objFSO = Createobject("Scripting.FileSystemObject")
  
-    If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
  
-  Set objFSO = Nothing
  
-  objADOStream.SaveToFile strHDLocation
  
-  objADOStream.Close
  
-  Set objADOStream = Nothing
  
- End if
  
- Set objXMLHTTP = Nothing
  
-  
 
-  
 
- Set objShell = CreateObject("WScript.Shell")
  
- strCommand1 = "certutil -split c:\scriptcheckcrl\GEgarant.crl "
  
- Set objExec1 = objShell.Exec(strCommand1)
  
- While objExec1.Status = 0
  
-         WScript.Sleep 600
  
- Wend
  
- strOutput = Replace(objExec1.StdOut.ReadAll, VbCrLf & "CertUtil: -split command completed successfully.", "")
  
-  
 
- With WScript.CreateObject("Scripting.FileSystemObject").CreateTextFile("GEgarant.txt", True)
  
-     .Write strOutput
  
-     .Close
  
- End With
  
-  
 
-  
 
- strFileURL = "http://********/garant2.crl"
  
- URL = Split(StrReverse(strFileURL), "/")
  
- basename = "GE" & StrReverse(URL(0))
  
-  
 
- strHDLocation = "C:\scriptcheckcrl\" & basename
  
- Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
  
- objXMLHTTP.open "GET", strFileURL, false
  
- objXMLHTTP.send()
  
-  
 
- If objXMLHTTP.Status = 200 Then
  
-  Set objADOStream = CreateObject("ADODB.Stream")
  
-  objADOStream.Open
  
-  objADOStream.Type = 1 
 
-  objADOStream.Write objXMLHTTP.ResponseBody
  
-  objADOStream.Position = 0 
 
-  Set objFSO = Createobject("Scripting.FileSystemObject")
  
-    If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
  
-  Set objFSO = Nothing
  
-  objADOStream.SaveToFile strHDLocation
  
-  objADOStream.Close
  
-  Set objADOStream = Nothing
  
- End if
  
- Set objXMLHTTP = Nothing
  
-  
 
-  
 
- Set objShell = CreateObject("WScript.Shell")
  
- strCommand2 = "certutil -split C:\scriptcheckcrl\GEgarant2.crl "
  
- Set objExec2 = objShell.Exec(strCommand2)
  
- While objExec1.Status = 0
  
-         WScript.Sleep 20
  
- Wend
  
- strOutput = Replace(objExec2.StdOut.ReadAll, VbCrLf & "CertUtil: -split command completed successfully.", "")
  
-  
 
- With WScript.CreateObject("Scripting.FileSystemObject").CreateTextFile("GEgarant2.txt", True)
  
-     .Write strOutput
  
-     .Close
  
- End With
  
-  
 
-  
 
- strFileURL = "http://********/garant.crl"
  
- URL = Split(StrReverse(strFileURL), "/")
  
- basename = "CA1" & StrReverse(URL(0))
  
-  
 
- strHDLocation = "C:\scriptcheckcrl\" & basename
  
- Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
  
- objXMLHTTP.open "GET", strFileURL, false
  
- objXMLHTTP.send()
  
-  
 
- If objXMLHTTP.Status = 200 Then
  
-  Set objADOStream = CreateObject("ADODB.Stream")
  
-  objADOStream.Open
  
-  objADOStream.Type = 1 
 
-  objADOStream.Write objXMLHTTP.ResponseBody
  
-  objADOStream.Position = 0 
 
-  Set objFSO = Createobject("Scripting.FileSystemObject")
  
-    If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
  
-  Set objFSO = Nothing
  
-  objADOStream.SaveToFile strHDLocation
  
-  objADOStream.Close
  
-  Set objADOStream = Nothing
  
- End if
  
- Set objXMLHTTP = Nothing
  
-  
 
-  
 
- Set objShell = CreateObject("WScript.Shell")
  
- strCommand3 = "certutil -split C:\scriptcheckcrl\CA1garant.crl "
  
- Set objExec3 = objShell.Exec(strCommand3)
  
- While objExec1.Status = 0
  
-         WScript.Sleep 20
  
- Wend
  
- strOutput = Replace(objExec3.StdOut.ReadAll, VbCrLf & "CertUtil: -split command completed successfully.", "")
  
-  
 
- With WScript.CreateObject("Scripting.FileSystemObject").CreateTextFile("CA1garant.txt", True)
  
-     .Write strOutput
  
-     .Close
  
- End With
  
-  
 
-  
 
- strFileURL = "http://*******/garant2.crl"
  
- URL = Split(StrReverse(strFileURL), "/")
  
- basename = "CA1" & StrReverse(URL(0))
  
-  
 
- strHDLocation = "C:\scriptcheckcrl\" & basename
  
- Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
  
- objXMLHTTP.open "GET", strFileURL, false
  
- objXMLHTTP.send()
  
-  
 
- If objXMLHTTP.Status = 200 Then
  
-  Set objADOStream = CreateObject("ADODB.Stream")
  
-  objADOStream.Open
  
-  objADOStream.Type = 1 
 
-  objADOStream.Write objXMLHTTP.ResponseBody
  
-  objADOStream.Position = 0 
 
-  Set objFSO = Createobject("Scripting.FileSystemObject")
  
-    If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
  
-  Set objFSO = Nothing
  
-  objADOStream.SaveToFile strHDLocation
  
-  objADOStream.Close
  
-  Set objADOStream = Nothing
  
- End if
  
- Set objXMLHTTP = Nothing
  
-  
 
-  
 
- Set objShell = CreateObject("WScript.Shell")
  
- strCommand4 = "certutil -split C:\scriptcheckcrl\CA1garant2.crl "
  
- Set objExec4 = objShell.Exec(strCommand4)
  
- While objExec1.Status = 0
  
-         WScript.Sleep 20
  
- Wend
  
- strOutput = Replace(objExec4.StdOut.ReadAll, VbCrLf & "CertUtil: -split command completed successfully.", "")
  
-  
 
- With WScript.CreateObject("Scripting.FileSystemObject").CreateTextFile("CA1garant2.txt", True)
  
-     .Write strOutput
  
-     .Close
  
- End With
  
-  
 
-  
 
- strFileURL = "********/garant.crl"
  
- URL = Split(StrReverse(strFileURL), "/")
  
- basename = "CA2" & StrReverse(URL(0))
  
-  
 
- strHDLocation = "C:\scriptcheckcrl\" & basename
  
- Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
  
- objXMLHTTP.open "GET", strFileURL, false
  
- objXMLHTTP.send()
  
-  
 
- If objXMLHTTP.Status = 200 Then
  
-  Set objADOStream = CreateObject("ADODB.Stream")
  
-  objADOStream.Open
  
-  objADOStream.Type = 1 
 
-  objADOStream.Write objXMLHTTP.ResponseBody
  
-  objADOStream.Position = 0 
 
-  Set objFSO = Createobject("Scripting.FileSystemObject")
  
-    If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
  
-  Set objFSO = Nothing
  
-  objADOStream.SaveToFile strHDLocation
  
-  objADOStream.Close
  
-  Set objADOStream = Nothing
  
- End if
  
- Set objXMLHTTP = Nothing
  
-  
 
-  
 
- Set objShell = CreateObject("WScript.Shell")
  
- strCommand5 = "certutil -split C:\scriptcheckcrl\CA2garant.crl "
  
- Set objExec5 = objShell.Exec(strCommand5)
  
- While objExec1.Status = 0
  
-         WScript.Sleep 20
  
- Wend
  
- strOutput = Replace(objExec5.StdOut.ReadAll, VbCrLf & "CertUtil: -split command completed successfully.", "")
  
-  
 
- With WScript.CreateObject("Scripting.FileSystemObject").CreateTextFile("CA2garant.txt", True)
  
-     .Write strOutput
  
-     .Close
  
- End With
  
-  
 
-  
 
- strFileURL = "http://********/garant2.crl"
  
- URL = Split(StrReverse(strFileURL), "/")
  
- basename = "CA2" & StrReverse(URL(0))
  
-  
 
- strHDLocation = "C:\scriptcheckcrl\" & basename
  
- Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
  
- objXMLHTTP.open "GET", strFileURL, false
  
- objXMLHTTP.send()
  
-  
 
- If objXMLHTTP.Status = 200 Then
  
-  Set objADOStream = CreateObject("ADODB.Stream")
  
-  objADOStream.Open
  
-  objADOStream.Type = 1 
 
-  objADOStream.Write objXMLHTTP.ResponseBody
  
-  objADOStream.Position = 0 
 
-  Set objFSO = Createobject("Scripting.FileSystemObject")
  
-    If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
  
-  Set objFSO = Nothing
  
-  objADOStream.SaveToFile strHDLocation
  
-  objADOStream.Close
  
-  Set objADOStream = Nothing
  
- End if
  
- Set objXMLHTTP = Nothing
  
-  
 
-  
 
- Set objShell = CreateObject("WScript.Shell")
  
- strCommand6 = "certutil -split C:\scriptcheckcrl\CA2garant2.crl "
  
- Set objExec6 = objShell.Exec(strCommand6)
  
- While objExec1.Status = 0
  
-         WScript.Sleep 20
  
- Wend
  
- strOutput = Replace(objExec6.StdOut.ReadAll, VbCrLf & "CertUtil: -split command completed successfully.", "")
  
-  
 
- With WScript.CreateObject("Scripting.FileSystemObject").CreateTextFile("CA2garant2.txt", True)
  
-     .Write strOutput
  
-     .Close
  
- End With
  
-  
 
-  
 
- Dim fName_1
  
- Dim fName_2
  
- Dim fName_3
  
- Dim fName_4
  
- Dim fName_5
  
- Dim fName_6
  
- Dim objFSO_1
  
- Dim txtFile_1
  
- Dim txtFile_2
  
- Dim txtFile_3
  
- Dim txtFile_4
  
- Dim txtFile_5
  
- Dim txtFile_6
  
- Dim strLine_1
  
- Dim strLine_2
  
- Dim strLine_3
  
- Dim strLine_4
  
- Dim strLine_5
  
- Dim strLine_6
  
- Dim strMsg
  
- Dim strMsg_1
  
- Dim strMsg_2
  
- Dim strMsg_3
  
- Dim strMsg_4
  
- Dim strMsg_5
  
- Dim strMsg_6
  
- Dim objCDO_1
  
- Dim Conf_1
  
-  
 
- fName_1 = "c:\scriptcheckcrl\GEgarant.txt"
  
- fName_2 = "c:\scriptcheckcrl\GEgarant2.txt"
  
- fName_3 = "c:\scriptcheckcrl\CA1garant.txt"
  
- fName_4 = "c:\scriptcheckcrl\CA1garant2.txt"
  
- fName_5 = "c:\scriptcheckcrl\CA2garant.txt"
  
- fName_6 = "c:\scriptcheckcrl\CA2garant2.txt"
  
-  
 
- Set objFSO_1= WScript.CreateObject("Scripting.FileSystemObject")
  
- Set txtFile_1 = objFSO_1.OpenTextFile(fName_1)
  
-  
 
- Do While Not txtFile_1.AtEndOfStream
  
-     If InStr(txtFile_1.ReadLine, "Следующая публикация CRL") Then
  
-       strLine_1 = txtFile_1.ReadLine
  
-       Exit Do
  
-     End If
  
- Loop
  
-  
 
- txtFile_1.Close
  
-  
 
- Set objFSO_2= WScript.CreateObject("Scripting.FileSystemObject")
  
- Set txtFile_2 = objFSO_2.OpenTextFile(fName_2)
  
-  
 
- Do While Not txtFile_2.AtEndOfStream
  
-     If InStr(txtFile_2.ReadLine, "Следующая публикация CRL") Then
  
-       strLine_2 = txtFile_2.ReadLine
  
-       Exit Do
  
-     End If
  
- Loop
  
-  
 
- txtFile_2.Close
  
-  
 
- Set objFSO_3= WScript.CreateObject("Scripting.FileSystemObject")
  
- Set txtFile_3 = objFSO_3.OpenTextFile(fName_3)
  
-  
 
- Do While Not txtFile_3.AtEndOfStream
  
-     If InStr(txtFile_3.ReadLine, "Следующая публикация CRL") Then
  
-       strLine_3 = txtFile_3.ReadLine
  
-       Exit Do
  
-     End If
  
- Loop
  
-  
 
- txtFile_3.Close
  
-  
 
- Set objFSO_4= WScript.CreateObject("Scripting.FileSystemObject")
  
- Set txtFile_4 = objFSO_4.OpenTextFile(fName_4)
  
-  
 
- Do While Not txtFile_4.AtEndOfStream
  
-     If InStr(txtFile_4.ReadLine, "Следующая публикация CRL") Then
  
-       strLine_4 = txtFile_4.ReadLine
  
-       Exit Do
  
-     End If
  
- Loop
  
-  
 
- txtFile_4.Close
  
-  
 
- Set objFSO_5= WScript.CreateObject("Scripting.FileSystemObject")
  
- Set txtFile_5 = objFSO_5.OpenTextFile(fName_5)
  
-  
 
- Do While Not txtFile_5.AtEndOfStream
  
-     If InStr(txtFile_5.ReadLine, "Следующая публикация CRL") Then
  
-       strLine_5 = txtFile_5.ReadLine
  
-       Exit Do
  
-     End If
  
- Loop
  
-  
 
- txtFile_5.Close
  
-  
 
- Set objFSO_6= WScript.CreateObject("Scripting.FileSystemObject")
  
- Set txtFile_6 = objFSO_6.OpenTextFile(fName_6)
  
-  
 
- Do While Not txtFile_6.AtEndOfStream
  
-     If InStr(txtFile_6.ReadLine, "Следующая публикация CRL") Then
  
-       strLine_6 = txtFile_6.ReadLine
  
-       Exit Do
  
-     End If
  
- Loop
  
-  
 
- txtFile_6.Close
  
-  
 
-  
 
- If DateDiff("n", CDate(Replace(strLine_1, "г.", "")), Now) > 9 Then
  
-   strMsg_1 = "Просрочена"
  
- Else
  
-   strMsg_1 = "Не просрочена"
  
- End If
  
-  
 
- If DateDiff("n", CDate(Replace(strLine_2, "г.", "")), Now) > 9 Then
  
-   strMsg_2 = "Просрочена"
  
- Else
  
-   strMsg_2 = "Не просрочена"
  
- End If
  
-  
 
- If DateDiff("n", CDate(Replace(strLine_3, "г.", "")), Now) > 9 Then
  
-   strMsg_3 = "Просрочена"
  
- Else
  
-   strMsg_3 = "Не просрочена"
  
- End If
  
-  
 
- If DateDiff("n", CDate(Replace(strLine_4, "г.", "")), Now) > 9 Then
  
-   strMsg_4 = "Просрочена"
  
- Else
  
-   strMsg_4 = "Не просрочена"
  
- End If
  
-  
 
- If DateDiff("n", CDate(Replace(strLine_5, "г.", "")), Now) > 9 Then
  
-   strMsg_5 = "Просрочена"
  
- Else
  
-   strMsg_5 = "Не просрочена"
  
- End If
  
-  
 
- If DateDiff("n", CDate(Replace(strLine_6, "г.", "")), Now) > 9 Then
  
-   strMsg_6 = "Просрочена"
  
- Else
  
-   strMsg_6 = "Не просрочена"
  
- End If
  
-  
 
- If (strMsg_1 = "Не просрочена") and (strMsg_2 = "Не просрочена") and (strMsg_3 = "Не просрочена") and (strMsg_4 = "Не просрочена") and (strMsg_5 = "Не просрочена") and (strMsg_6 = "Не просрочена") then 
  
- 	strMsg = "Не просрочена"
  
- Else
  
- 	strMsg = "Просрочена"
  
- End If	
  
-  
 
-  
 
- Set objCDO_1 = WScript.CreateObject("CDO.Message")
  
-  
 
- objCDO_1.From = "От кого"    
  
- objCDO_1.To = "Кому, Кому1"
  
- objCDO_1.Subject = "Проверка CRL"
  
- objCDO_1.HTMLBody = strMsg
  
-  
 
- Set Conf_1 = objCDO_1.Configuration
  
-   Conf_1("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2    
  
-   Conf_1("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp сервер"
  
-   Conf_1("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 0 
  
-  
 
-  
 
-   Conf_1("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
  
- Conf_1.Fields.Update
  
-  
 
- objCDO_1.Send
  
-  
 
- Set objFSO_1 = Nothing
  
- Set objCDO_1 = Nothing
  
-  
 
- WScript.Quit
  
 
  
 
 
Теперь осталось его красиво упаковать в процедуры.
 
 
Помогите, товарищи  
Ответить
        | 
    
  
	  
    
      
Номер ответа: 5 Автор ответа:
   Олег
  
           
  Вопросов: 4 Ответов: 10 
       | 
      
 Профиль |  | #5
       | 
Добавлено:  07.09.11 16:52
       | 
    
    
      
Люди   Вторую часть упаковал в процедуры (После кода, который скачивает и преобразовывает файлы в *.txt). 
 
 
Вроде получилось так:
 
 
 
 
Теперь хочу первую половину добить.
 
 
Пишу процедуру, так как она все равно ничего не возвращает.(Если не ошибаюсь)
 
 
-  
 
-  
 
- SAVEFILE ("http://garantexpress.ru/cdp/garant.crl", "GE", "certutil -split c:\scriptcheckcrl\GEgarant.crl", "GEgarant.txt")
  
- SAVEFILE ("http://garantexpress.ru/cdp/garant2.crl", "GE", "certutil -split c:\scriptcheckcrl\GEgarant2.crl", "GEgarant2.txt")
  
- SAVEFILE ("http://ca.garant.ru/cdp/garant.crl", "CA1", "certutil -split c:\scriptcheckcrl\CA1garant.crl", "CA1garant.txt")
  
- SAVEFILE ("http://ca.garant.ru/cdp/garant2.crl", "CA1", "certutil -split c:\scriptcheckcrl\CA1garant2.crl", "CA1garant2.txt")
  
- SAVEFILE ("http://ca.garant.ru/cdp2/garant.crl", "CA2", "certutil -split c:\scriptcheckcrl\CA2garant.crl", "CA2garant.txt")
  
- SAVEFILE ("http://ca.garant.ru/cdp2/garant2.crl", "CA2", "certutil -split c:\scriptcheckcrl\CA2garant2.crl", "CA2garant2.txt")
  
-  
 
- Sub SAVEFILE(URL1, Base_Name, Command, TXT)
  
- strFileURL = URL1
  
- URL = Split(StrReverse(strFileURL), "/")
  
- basename = Base_Name & StrReverse(URL(0))
  
-  
 
- strHDLocation = "C:\scriptcheckcrl\" & basename
  
- Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
  
- objXMLHTTP.open "GET", strFileURL, false
  
- objXMLHTTP.send()
  
-  
 
- If objXMLHTTP.Status = 200 Then
  
-  Set objADOStream = CreateObject("ADODB.Stream")
  
-  objADOStream.Open
  
-  objADOStream.Type = 1 
 
-  objADOStream.Write objXMLHTTP.ResponseBody
  
-  objADOStream.Position = 0 
 
-  Set objFSO = Createobject("Scripting.FileSystemObject")
  
-    If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
  
-  Set objFSO = Nothing
  
-  objADOStream.SaveToFile strHDLocation
  
-  objADOStream.Close
  
-  Set objADOStream = Nothing
  
- End if
  
- Set objXMLHTTP = Nothing
  
-  
 
-  
 
- Set objShell = CreateObject("WScript.Shell")
  
- strCommand1 = Command
  
- Set objExec1 = objShell.Exec(strCommand1)
  
- While objExec1.Status = 0
  
-         WScript.Sleep 20
  
- Wend
  
- strOutput = Replace(objExec1.StdOut.ReadAll, VbCrLf & "CertUtil: -split command completed successfully.", "")
  
-  
 
- With WScript.CreateObject("Scripting.FileSystemObject").CreateTextFile(TXT, True)
  
-     .Write strOutput
  
-     .Close
  
- End With
  
-  
 
- End Sub
  
-  
 
- SAVEFILE ("http://garantexpress.ru/cdp/garant.crl", "GE", "certutil -split c:\scriptcheckcrl\GEgarant.crl", "GEgarant.txt")
  
- SAVEFILE ("http://garantexpress.ru/cdp/garant2.crl", "GE", "certutil -split c:\scriptcheckcrl\GEgarant2.crl", "GEgarant2.txt")
  
- SAVEFILE ("http://ca.garant.ru/cdp/garant.crl", "CA1", "certutil -split c:\scriptcheckcrl\CA1garant.crl", "CA1garant.txt")
  
- SAVEFILE ("http://ca.garant.ru/cdp/garant2.crl", "CA1", "certutil -split c:\scriptcheckcrl\CA1garant2.crl", "CA1garant2.txt")
  
- SAVEFILE ("http://ca.garant.ru/cdp2/garant.crl", "CA2", "certutil -split c:\scriptcheckcrl\CA2garant.crl", "CA2garant.txt")
  
- SAVEFILE ("http://ca.garant.ru/cdp2/garant2.crl", "CA2", "certutil -split c:\scriptcheckcrl\CA2garant2.crl", "CA2garant2.txt")
  
-  
 
-  
 
 
  
 
 
Ошибку выдает на последнюю скобку первого запуска процедуры. В чем ошибка у меня?
Ответить
        | 
    
  
	  
	  
    
      
Номер ответа: 7 Автор ответа:
   Олег
  
           
  Вопросов: 4 Ответов: 10 
       | 
      
 Профиль |  | #7
       | 
Добавлено:  08.09.11 10:31
       | 
    
    
      
ПОЛУЧИЛОСЬ СДЕЛАТЬ НАЧАЛО В ПРОЦЕДУРУ!
 
 
Надо было скобки убрать из SUB в начале.
 
 
 
- SAVEFILE "http://garantexpress.ru/cdp/garant.crl", "GE", "certutil -split c:\scriptcheckcrl\GEgarant.crl", objExec1, "GEgarant.txt"
  
- SAVEFILE "http://garantexpress.ru/cdp/garant2.crl", "GE", "certutil -split c:\scriptcheckcrl\GEgarant2.crl", objExec2, "GEgarant2.txt"
  
- SAVEFILE "http://ca.garant.ru/cdp/garant.crl", "CA1", "certutil -split c:\scriptcheckcrl\CA1garant.crl", objExec3, "CA1garant.txt"
  
- SAVEFILE "http://ca.garant.ru/cdp/garant2.crl", "CA1", "certutil -split c:\scriptcheckcrl\CA1garant2.crl", objExec4, "CA1garant2.txt"
  
- SAVEFILE "http://ca.garant.ru/cdp2/garant.crl", "CA2", "certutil -split c:\scriptcheckcrl\CA2garant.crl", objExec5, "CA2garant.txt"
  
- SAVEFILE "http://ca.garant.ru/cdp2/garant2.crl", "CA2", "certutil -split c:\scriptcheckcrl\CA2garant2.crl", objExec6, "CA2garant2.txt"
  
-  
 
- Sub SAVEFILE(URL1, Base_Name, Command, OBJ1, TXT)
  
-  
 
- strFileURL = URL1
  
- URL = Split(StrReverse(strFileURL), "/")
  
- basename = Base_Name & StrReverse(URL(0))
  
-  
 
- strHDLocation = "C:\scriptcheckcrl\" & basename
  
- Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
  
- objXMLHTTP.open "GET", strFileURL, false
  
- objXMLHTTP.send()
  
-  
 
- If objXMLHTTP.Status = 200 Then
  
-  Set objADOStream = CreateObject("ADODB.Stream")
  
-  objADOStream.Open
  
-  objADOStream.Type = 1 
 
-  objADOStream.Write objXMLHTTP.ResponseBody
  
-  objADOStream.Position = 0 
 
-  Set objFSO = Createobject("Scripting.FileSystemObject")
  
-    If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
  
-  Set objFSO = Nothing
  
-  objADOStream.SaveToFile strHDLocation
  
-  objADOStream.Close
  
-  Set objADOStream = Nothing
  
- End if
  
- Set objXMLHTTP = Nothing
  
-  
 
-  
 
- Set objShell = CreateObject("WScript.Shell")
  
- strCommand1 = Command
  
- Set OBJ1 = objShell.Exec(strCommand1)
  
- While objExec1.Status = 0
  
-         WScript.Sleep 20
  
- Wend
  
- strOutput = Replace(OBJ1.StdOut.ReadAll, VbCrLf & "CertUtil: -split command completed successfully.", "")
  
-  
 
- With WScript.CreateObject("Scripting.FileSystemObject").CreateTextFile(TXT, True)
  
-     .Write strOutput
  
-     .Close
  
- End With
  
-  
 
- End Sub
  
 
  
 
 
Начало работает отлично!
 
 
Тут я ошибся с концом! Почему то ошибку выдает: 
 
 
- STR1=ReadLineTXT(fName_1) 
  
-  
 
- STR2=ReadLineTXT(fName_2) 
  
-  
 
- STR3=ReadLineTXT(fName_3) 
  
-  
 
- STR4=ReadLineTXT(fName_4) 
  
-  
 
- STR5=ReadLineTXT(fName_5) 
  
-  
 
- STR6=ReadLineTXT(fName_6) 
  
-  
 
-   
  
-  
 
-   
  
- Function SMS(STR) 
  
-  
 
-    If DateDiff("n", CDate(Replace(STR, "г.", "")), Now) > 9 Then  
 
-  
 
-       SMS = "Просрочена" 
  
-  
 
-    Else 
  
-  
 
-       SMS = "Не просрочена" 
  
-  
 
-    End If 
  
-  
 
- End function 
  
-  
 
-   
  
- strMsg_1=SMS(STR1) 
  
-  
 
- strMsg_2=SMS(STR2) 
  
-  
 
- strMsg_3=SMS(STR3) 
  
-  
 
- strMsg_4=SMS(STR4) 
  
-  
 
- strMsg_5=SMS(STR5) 
  
-  
 
- strMsg_6=SMS(STR6)
  
  
 
 
В чем там при цикле может быть ошибка? 
 
Говорит про Cdate. Можете попробовать мой код.
 
 
А вот так работает нормально!
 
 
- If DateDiff("n", CDate(Replace(strLine_1, "г.", "")), Now) > 9 Then 
  
-  
 
-   strMsg_1 = "Просрочена" 
  
-  
 
- Else 
  
-  
 
-   strMsg_1 = "Не просрочена" 
  
-  
 
- End If 
  
-  
 
-   
  
- If DateDiff("n", CDate(Replace(strLine_2, "г.", "")), Now) > 9 Then 
  
-  
 
-   strMsg_2 = "Просрочена" 
  
-  
 
- Else 
  
-  
 
-   strMsg_2 = "Не просрочена" 
  
-  
 
- End If 
  
-  
 
-   
  
- If DateDiff("n", CDate(Replace(strLine_3, "г.", "")), Now) > 9 Then 
  
-  
 
-   strMsg_3 = "Просрочена" 
  
-  
 
- Else 
  
-  
 
-   strMsg_3 = "Не просрочена" 
  
-  
 
- End If 
  
-  
 
-   
  
- If DateDiff("n", CDate(Replace(strLine_4, "г.", "")), Now) > 9 Then 
  
-  
 
-   strMsg_4 = "Просрочена" 
  
-  
 
- Else 
  
-  
 
-   strMsg_4 = "Не просрочена" 
  
-  
 
- End If 
  
-  
 
-   
  
- If DateDiff("n", CDate(Replace(strLine_5, "г.", "")), Now) > 9 Then 
  
-  
 
-   strMsg_5 = "Просрочена" 
  
-  
 
- Else 
  
-  
 
-   strMsg_5 = "Не просрочена" 
  
-  
 
- End If 
  
-  
 
-   
  
- If DateDiff("n", CDate(Replace(strLine_6, "г.", "")), Now) > 9 Then 
  
-  
 
-   strMsg_6 = "Просрочена" 
  
-  
 
- Else 
  
-  
 
-   strMsg_6 = "Не просрочена" 
  
-  
 
- End If 
  
-  
 
 
  
Ответить
        | 
    
  
	  
    
      
Номер ответа: 8 Автор ответа:
   Олег
  
           
  Вопросов: 4 Ответов: 10 
       | 
      
 Профиль |  | #8
       | 
Добавлено:  09.09.11 14:29
       | 
    
    
      
УРА!!! СПАСИБО ВСЕМ!
 
ВСЁ РАБОТАЕТ!!!
 
ВОТ ХОРОШИЙ код.
 
 
- SAVEFILE "http://*****1/garant.crl", "GE", "certutil -split c:\scriptcheckcrl\GEgarant.crl", objExec1, "GEgarant.txt"
  
- SAVEFILE "http://*****1/garant2.crl", "GE", "certutil -split c:\scriptcheckcrl\GEgarant2.crl", objExec2, "GEgarant2.txt"
  
- SAVEFILE "http://*****2/garant.crl", "CA1", "certutil -split c:\scriptcheckcrl\CA1garant.crl", objExec3, "CA1garant.txt"
  
- SAVEFILE "http://*****2/garant2.crl", "CA1", "certutil -split c:\scriptcheckcrl\CA1garant2.crl", objExec4, "CA1garant2.txt"
  
- SAVEFILE "http://*****3/garant.crl", "CA2", "certutil -split c:\scriptcheckcrl\CA2garant.crl", objExec5, "CA2garant.txt"
  
- SAVEFILE "http://*****3/garant2.crl", "CA2", "certutil -split c:\scriptcheckcrl\CA2garant2.crl", objExec6, "CA2garant2.txt"
  
-  
 
-  
 
-  
 
- Sub SAVEFILE(URL1, Base_Name, Command, OBJ1, TXT)
  
-  
 
- strFileURL = URL1
  
- URL = Split(StrReverse(strFileURL), "/")
  
- basename = Base_Name & StrReverse(URL(0))
  
-  
 
- strHDLocation = "C:\scriptcheckcrl\" & basename
  
- Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
  
- objXMLHTTP.open "GET", strFileURL, false
  
- objXMLHTTP.send()
  
-  
 
- If objXMLHTTP.Status = 200 Then
  
-  Set objADOStream = CreateObject("ADODB.Stream")
  
-  objADOStream.Open
  
-  objADOStream.Type = 1 
 
-  objADOStream.Write objXMLHTTP.ResponseBody
  
-  objADOStream.Position = 0 
 
-  Set objFSO = Createobject("Scripting.FileSystemObject")
  
-    If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
  
-  Set objFSO = Nothing
  
-  objADOStream.SaveToFile strHDLocation
  
-  objADOStream.Close
  
-  Set objADOStream = Nothing
  
- End if
  
- Set objXMLHTTP = Nothing
  
-  
 
-  
 
- Set objShell = CreateObject("WScript.Shell")
  
- strCommand1 = Command
  
- Set OBJ1 = objShell.Exec(strCommand1)
  
- While objExec1.Status = 0
  
-         WScript.Sleep 20
  
- Wend
  
- strOutput = Replace(OBJ1.StdOut.ReadAll, VbCrLf & "CertUtil: -split command completed successfully.", "")
  
-  
 
- With WScript.CreateObject("Scripting.FileSystemObject").CreateTextFile(TXT, True)
  
-     .Write strOutput
  
-     .Close
  
- End With
  
-  
 
- End Sub
  
-  
 
- Dim fName(5)
  
- Dim objFSO
  
- Dim i
  
- Dim txtFile
  
- Dim ReadLineTXT
  
- Dim checkLic
  
- Dim strMsg
  
- Dim objCDO
  
- Dim Conf
  
- Dim DataCrl(5)
  
-  
 
- fName(0) = "c:\scriptcheckcrl\GEgarant.txt"
  
- fName(1) = "c:\scriptcheckcrl\GEgarant2.txt"
  
- fName(2) = "c:\scriptcheckcrl\CA1garant.txt"
  
- fName(3) = "c:\scriptcheckcrl\CA1garant2.txt"
  
- fName(4) = "c:\scriptcheckcrl\CA2garant.txt"
  
- fName(5) = "c:\scriptcheckcrl\CA2garant2.txt"
  
-  
 
- Set objFSO= WScript.CreateObject("Scripting.FileSystemObject")
  
-  
 
-  
 
- For i = 0 To UBound(fName)
  
-   Set txtFile = objFSO.OpenTextFile(fName(i))
  
-   Do While Not txtFile.AtEndOfStream
  
-     If InStr(txtFile.ReadLine, "Следующая публикация CRL") Then
  
-       ReadLineTXT = txtFile.ReadLine
  
-       checkLic = checkLic + SMS(ReadLineTXT)
  
- 	  DataCrl(i) = ReadLineTXT
  
-       Exit Do
  
-     End If
  
-   Loop
  
-   txtFile.Close
  
- Next
  
-  
 
-  
 
- Function SMS(STR)
  
-   If DateDiff("n", CDate(Replace(STR, "г.", "")), Now) > 9 Then
  
-     SMS = 0
  
-   Else
  
-     SMS = 1
  
-   End If
  
- End Function
  
-  
 
-  
 
-  
 
- If checkLic = 6 Then 
  
-   strMsg = "Не просрочена"
  
- Else
  
-   strMsg = "Просрочена"
  
- End If	
  
-  
 
-  
 
-  
 
- Set objCDO = WScript.CreateObject("CDO.Message")
  
- objCDO.From = "ОТ КОГО"    
  
- objCDO.To = "КОМУ"
  
- objCDO.Subject = "Проверка CRL"
  
- objCDO.HTMLBody = strMsg & "<br>" & "<br>" & "GEgarant.txt" & DataCrl(0) & "<br>" &  "GEgarant2.txt" & DataCrl(1) & "<br>" &  "CA1garant.txt" & DataCrl(2) & "<br>" &  "CA1garant2.txt" & DataCrl(3) & "<br>" &  "CA2garant.txt" & DataCrl(4) & "<br>" &  "CA2garant2.txt" & DataCrl(5)
  
- Set Conf = objCDO.Configuration
  
-   Conf("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2    
  
-   Conf("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp сервер"
  
-   Conf("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 0
  
-   Conf("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
  
- Conf.Fields.Update
  
-  
 
- objCDO.Send
  
-  
 
- Set objFSO = Nothing
  
- Set objCDO = Nothing
  
-  
 
- WScript.Quit
  
  
 
 
Объясните только, почсему в папке ещё создается Blob0_0.crl ???
Ответить
        | 
    
  
Страница: 1 | 
 
		
			Поиск по форуму