Introduction
MTFC: Microsoft Technical French Contributor est un Award conçu et réalisé par l'équipe des Wiki Ninjas dirigé par Ed Price. Cet Award à comme but de remercier toute personne qui à contribué dans les Forum TechNet France. Pour plus d'informations vous pouvez lire ceci: http://blogs.technet.com/b/wikininjas/archive/2013/03/17/week-end-surprise-four-fantastic-presents-the-microsoft-technical-french-contributor.aspxPour d'autres questions ou remarques vous pouvez envoyer un mail vers: tnwikifrenchdayga@outlook.com
Références
Cet artcile à été écrit par: celegorm dans le contexte: Appel à la Contribution 17/04/2013 - 17/06/2013. L'article est l'heureux gagnant dans la catégorie Windows 7.L'article
'-----------------------------------------------------------------'ce programme est destiné à maintenir à jour des fichiers présents en local et sur le net'attention, utilise des fichiers .zip (local et web)'demande la présence des fichiers .zip dans la racine local avant de démarrer'fichier fciv source officielle: http://www.microsoft.com/en-us/download/details.aspx?id=11533'fichier unzip source officielle: http://stahlworks.com/dev/unzip.exedim identiquedim commandlinedim checksum_fichierolddim checksum_fichiernewdim shadim racinedim source_webdim fcivdim unzipdim source_fcivdim source_unzipSet fso = CreateObject("Scripting.FileSystemObject" )Set OWS = CreateObject("Wscript.Shell")'------------ variables personnalisables------------------dim nom_des_fichiers(1) 'à augmenter suivant le nombre de fichier suivi (n-1)nom_des_fichiers(0)=("Autoruns.zip")nom_des_fichiers(1)=("ProcessExplorer.zip")racine="le répertoire où sont stockés process explorer.zip et autoruns.zip"source_web="http://download.sysinternals.com/files/"rep_programme="répertoire où sont stockés les programmes de sysinternals"fciv="répertoire où est stocké fciv\fciv.exe"source_fciv="http://www.softpratik.fr/fciv.exe"unzip="répertoire où est stocké unzip \unzip.exe"source_unzip="http://www.softpratik.fr/unzip.exe"'---------------------------------------------------------'----prog principal----initialisationfor x=0 to ubound(nom_des_fichiers) check_fichier racine & nom_des_fichiers(x) Importer_Fichier_Du_Web source_web & nom_des_fichiers(x),racine & nom_des_fichiers(x) comparer_checksum racine & nom_des_fichiers(x), racine & nom_des_fichiers(x) & ".old" if identique=1 then 'si le fichier téléchargé est identique
au précédent, on le supprime et on renomme le .old en .zip fso.deletefile racine & nom_des_fichiers(x) fso.MoveFile racine & nom_des_fichiers(x) & ".old",racine
& nom_des_fichiers(x) else' si le fichier téléchargé est différent, on dézippe
le fichier dans le répertoire sysinternals et on supprime le fichier .old unzipper_fichier racine & nom_des_fichiers(x),rep_programme fso.deletefile racine & nom_des_fichiers(x) & ".old" msgbox ("le programme "& nom_des_fichiers(x)
& " a été mis à jour") end ifnext'----les sous-programmes----sub initialisation 'va télécharger fciv et unzip s'ils ne sont pas présents If Not fso.FileExists(fciv) then Importer_Fichier_Du_Web source_fciv,fciv End If If Not fso.FileExists(unzip) then Importer_Fichier_Du_Web source_unzip,unzip End IfEnd SubSub check_fichier(fichier)'va renommer les fichiers présent en .old If fso.FileExists(fichier) then If fso.FileExists(fichier & ".old") then fso.deletefile fichier & ".old" End If fso.MoveFile fichier,fichier & ".old" End IfEnd SubSub Importer_Fichier_Du_Web(source,destination)'récupère les fichiers sur le site Set HTTP=Objet_XMLHTTP With HTTP .Open "GET",source,False .Send End With With CreateObject("ADODB.Stream") .Type=1 .Open .Write HTTP.ResponseBody .SaveToFile destination,2 End With End Sub Function Objet_XMLHTTP 'crée un objet xmlhttp On Error Resume Next Set Objet_XMLHTTP=CreateObject("Microsoft.XMLHTTP") Set Objet_XMLHTTP=CreateObject("MSXML2.XMLHTTP") On Error GoTo 0 End Function Sub comparer_checksum (fichierold,fichiernew) 'compare le checksum de 2 fichiers avec l'outil
fciv Set fso = CreateObject("Scripting.FileSystemObject" ) checksum (fichierold) checksum_fichierold=sha fso.deletefile racine & "checksum.xml" checksum (fichiernew) checksum_fichiernew=sha fso.deletefile racine & "checksum.xml" If checksum_fichierold=checksum_fichiernew then identique=1 Else identique=0 End IfEnd SubFunction checksum (fichier) Set xmldoc = CreateObject("Microsoft.XMLDOM") xmldoc.async=false commandline= "cmd /c " & fciv & "
-add " & fichier & " -sha1 -wp -xml " &racine &"checksum.xml" OWS.Run (commandline),0 WScript.Sleep 2000 xmldoc.load(racine & "checksum.xml") For each fichier in xmlDoc.selectNodes("/FCIV/FILE_ENTRY") sha=fichier.selectSingleNode("SHA1").text< -sha1 -wp -x/code> NextEnd FunctionFunction unzipper_fichier(strZipFile, strFolder) ' décompresse le fichier zip commandline= "cmd /c " & unzip & "
-o " & strZipFile & " -d " & """"& strFolder &"""" OWS.Run (commandline),0 WScript.Sleep 2000End Function