1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
| Option Explicit
Const LOG_FILE_PATH = "LogInstall.txt"
Dim Titre,MsgAttente,oExec,fso,ws,Temp,PathScript,Question,MaCmd
Titre = "Downloading File by © Hackoo 2014"
Set ws = CreateObject("wscript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(LOG_FILE_PATH) Then fso.DeleteFile(LOG_FILE_PATH)
Temp = ws.ExpandEnvironmentStrings("%Temp%")
Call DownloadingFile("http://download.pdfforge.org/download/pdfcreator/PDFCreator-stable?download")
Titre = "Installation de "& DblQuote("PDFCreator") &" by © Hackoo 2014"
MsgAttente = "Veuillez patienter. Installation de "& DblQuote("PDFCreator") &" est en cours..."
Call CreateProgressBar(Titre,MsgAttente)'Creation de barre de progression
Call LancerProgressBar() 'Launch of the progress bar
Log LOG_FILE_PATH, String(10,"*") & Now & String(10,"*") & vbCrLf & "Début de l'installation silencieuse de PDFCreator" & vbCrLf & String(70,"*")
MaCmd = "Start /Wait /Min PDFCreator.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-"
If Executer(MaCmd,0) <> 0 Then
Log LOG_FILE_PATH, "Echec lors de l'installation"
Else
Log LOG_FILE_PATH, "Installation de PDFCreator réussie"
End If
Log LOG_FILE_PATH, String(10,"*") & Now & String(10,"*") & vbCrLf & "Fin de l'installation silencieuse de PDFCreator" & vbCrLf & String(70,"*")
Call FermerProgressBar() 'Closing progress bar
ws.Run LOG_FILE_PATH
'********************************************************************************************************************
Sub DownloadingFile(URL)
Dim Titre,objFSO,Ws,objXMLHTTP,PathScript,Tab,strHDLocation,objADOStream,Command,Start,File
Dim MsgTitre,MsgAttente,StartTime,DurationTime,ProtocoleHTTP
Set objFSO = Createobject("Scripting.FileSystemObject")
Set Ws = CreateObject("wscript.Shell")
PathScript = fso.GetParentFolderName(wscript.ScriptFullName) 'Path of this Vbscript
ProtocoleHTTP = "http://"
If URL = "" Then WScript.Quit
If Left(URL,7) <> ProtocoleHTTP Then
URL = ProtocoleHTTP & URL
End if
File = "PDFCreator.exe"
Titre = "Downloading File : " & Dblquote(File) & " © Hackoo 2014"
Set objXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP.3.0")
strHDLocation = PathScript & "\" & File
MsgAttente = "Veuillez patienter. Téléchargement de "& DblQuote("PDFCreator") &" en progression..."
Call CreateProgressBar(Titre,MsgAttente)'Creation de barre de progression
Call LancerProgressBar() 'Launch of the progress bar
StartTime = Timer 'Start the Timer Counter
On Error Resume Next
objXMLHTTP.open "GET",URL,false
objXMLHTTP.send()
If Err.number <> 0 Then
Call FermerProgressBar()'Closing progress bar
MsgBox err.description,16,err.description
Exit Sub
Else
If objXMLHTTP.Status = 200 Then
strHDLocation = PathScript & "\" & File
Set objADOStream = CreateObject("ADODB.Stream")
objADOStream.Open
objADOStream.Type = 1 'adTypeBinary
objADOStream.Write objXMLHTTP.ResponseBody
objADOStream.Position = 0 'Set the stream position to the start
If objFSO.FileExists(strHDLocation) Then objFSO.DeleteFile strHDLocation
objADOStream.SaveToFile strHDLocation
objADOStream.Close
Set objADOStream = Nothing
End If
End if
Set objXMLHTTP = Nothing
DurationTime = FormatNumber(Timer - StartTime, 0) & " seconds." 'The duration of the script
Call FermerProgressBar() 'Closing progress bar
ws.Popup "The Download of " & Dblquote(File) & " is finished in " & DurationTime &" !","3","The Download of " & Dblquote(File) & " is finished in " & DurationTime &" !",64
End Sub
'****************************************************************************************************
Sub CreateProgressBar(Titre,MsgAttente)
Dim ws,fso,f,f2,ts,ts2,Ligne,i,fread,LireTout,NbLigneTotal,Temp,PathOutPutHTML,fhta,oExec
Set ws = CreateObject("wscript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Temp = WS.ExpandEnvironmentStrings("%Temp%")
PathOutPutHTML = Temp & "\Barre.hta"
Set fhta = fso.OpenTextFile(PathOutPutHTML,2,True)
fhta.WriteLine "<HTML>"
fhta.WriteLine "<HEAD>"
fhta.WriteLine "<Title> " & Titre & "</Title>"
fhta.WriteLine "<HTA:APPLICATION"
fhta.WriteLine "ICON = ""magnify.exe"" "
fhta.WriteLine "BORDER=""THIN"" "
fhta.WriteLine "INNERBORDER=""NO"" "
fhta.WriteLine "MAXIMIZEBUTTON=""NO"" "
fhta.WriteLine "MINIMIZEBUTTON=""NO"" "
fhta.WriteLine "SCROLL=""NO"" "
fhta.WriteLine "SYSMENU=""NO"" "
fhta.WriteLine "SELECTION=""NO"" "
fhta.WriteLine "SINGLEINSTANCE=""YES"">"
fhta.WriteLine "</HEAD>"
fhta.WriteLine "<BODY text=""white""><CENTER><DIV><SPAN ID=""ProgressBar""></SPAN>"
fhta.WriteLine "<span><marquee DIRECTION=""LEFT"" SCROLLAMOUNT=""3"" BEHAVIOR=ALTERNATE><font face=""Comic sans MS"">" & MsgAttente &"</font></marquee></span></DIV></CENTER></BODY></HTML>"
fhta.WriteLine "<SCRIPT LANGUAGE=""VBScript""> "
fhta.WriteLine "Set ws = CreateObject(""wscript.Shell"")"
fhta.WriteLine "Temp = WS.ExpandEnvironmentStrings(""%Temp%"")"
fhta.WriteLine "Sub window_onload()"
fhta.WriteLine " CenterWindow 430,90"
fhta.WriteLine " Self.document.bgColor = ""Orange"" "
fhta.WriteLine " End Sub"
fhta.WriteLine " Sub CenterWindow(x,y)"
fhta.WriteLine " Dim iLeft,itop"
fhta.WriteLine " window.resizeTo x,y"
fhta.WriteLine " iLeft = window.screen.availWidth/2 - x/2"
fhta.WriteLine " itop = window.screen.availHeight/2 - y/2"
fhta.WriteLine " window.moveTo ileft,itop"
fhta.WriteLine "End Sub"
fhta.WriteLine "</script>"
fhta.close
End Sub
'**********************************************************************************************
Sub LancerProgressBar()
Set oExec = Ws.Exec("mshta.exe " & Temp & "\Barre.hta")
End Sub
'**********************************************************************************************
Sub FermerProgressBar()
oExec.Terminate
End Sub
'**********************************************************************************************
Function DblQuote(Str)
DblQuote = Chr(34) & Str & Chr(34)
End Function
'**********************************************************************************************
Function Executer(StrCmd,Console)
'Console : valeur 0 pour cacher la console MS-DOS, valeur 1 pour montrer la console MS-DOS
Dim ws,MyCmd,Resultat
Set ws = CreateObject("wscript.Shell")
MyCmd = "CMD /C " & StrCmd & ""
Log LOG_FILE_PATH, "Lancement de la commande ==> " & DblQuote(MyCmd)
Resultat = ws.run(MyCmd,Console,True)
Log LOG_FILE_PATH, "Code retour ==> " & DblQuote(Resultat)
Executer = Resultat
End Function
'**********************************************************************************************
Sub Log(strLogFilePath,strLogContent)
Const APPEND = 8
Dim objFso, objLogFile
Set objFso = CreateObject("Scripting.FileSystemObject")
If Not objFso.FileExists(strLogFilePath) Then objFso.CreateTextFile(strLogFilePath, True).Close
Set objLogFile = objFso.OpenTextFile(strLogFilePath, APPEND)
objLogFile.WriteLine strLogContent
objLogFile.Close
End Sub
'********************************************************************************************** |
Partager