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
| Dim oFSO, fichierVbs, f, wshell, dossierDB
Const ForWriting = 2
Set wshell = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FilesystemObject")
dossierDB = "C:\Documents and Settings\Administrateur\Bureau\apps\absys\EXPORTSOCS\Dropbox\Test"
fichierSev = "C:\ProgramData\OCS Inventory NG\Agent\*.xml"
FichierXP = "C:\Documents and Settings\All Users\Application Data\OCS Inventory NG\Agent\*.xml"
SysSev = "C:\ProgramData"
SysXp = "C:\Documents and Settings\All Users\Application Data"
if oFSO.FolderExists(SysSev) then ' Je test pour savoir si c'est un seven en fonction de l'existence du dossier ProgramData
if oFSO.FileExists(fichierSev) then
Set oF1 = oFSO.GetFile(fichierSev) ' Je vais chercher tout les informations sur le fichier
fromDate = oF1.dateCreated ' Je stock la date de création dans une variable pour la maethode DateDiff
toDate = Now ' La date du moment ou est lancé le script
DiffTps = DateDiff("m", fromDate, toDate) ' Stock la valeur du mois pour l'utlisé dans la condition ci-dessous
if DiffTps > 6 then ' Si la date de création est sup a 6 mois alors je supprime le fichier et je lance l'ocspackager.exe qui générera un nouveau xml
oFSO.DeleteFile "C:\ProgramData\OCS Inventory NG\Agent\*.xml",True
wshell.run "\\192.168.69.21\apps\absys\scriptocs.bat"
Wscript.Sleep(2000) ' Une pause de 2sec pour laisser le script bat creer les fichiers necessaires à la suite du script.
oFSO.CopyFile "C:\ProgramData\OCS Inventory NG\Agent\*.xml", "\\192.168.69.21\apps\ABSYS\EXPORTSOCS\Dropbox\Test", True
else
Set f = oFSO.OpenTextFile("c:\Programmes\ocs.txt", ForWriting,true)
f.writeline("Analysé le " + Now + ".")
end if
else
wshell.run "\\192.168.69.21\apps\absys\scriptocs.bat"
Wscript.Sleep(5000)
oFSO.CopyFile "C:\ProgramData\OCS Inventory NG\Agent\*.xml", "\\192.168.69.21\apps\ABSYS\EXPORTSOCS\Dropbox\Test", True
end if
else
if ofso.FolderExists(sysxp) then ' Je test pour savoir si c'est un xp en fonction de l'existence du dossier Application Data
if oFSO.FileExists(fichierxp) = false then
oF1 = oFSo.GetFile(fichierxp) ' Recuperer les proprietés du fichier xml présent dans le dossier Agent.
fromDate = oF1.created ' stocker la valeur de la date de création
toDate = Now ' stocker la valeur de la date du systeme a l'instant ou s'execute le script
DiffTps = DateDiff("m", fromDate, toDate) ' Calcule la difference de mois entre la création et l'execution du script
if Difftps > 6 then ' Si la difference est de + de 6 mois alors
ofso.deletefile "C:\Documents and Settings\All Users\Application Data\OCS Inventory NG\Agent\*.xml" ' On supprime le vieux fichier
wshell.run "\\192.168.69.21\apps\absys\scriptocs.bat" ' On llance le script permettant d'en creer un nouveau
ofso.copyfile "C:\Documents and Settings\All Users\Application Data\OCS Inventory NG\Agent\*.xml", "\\192.168.69.21\apps\ABSYS\EXPORTSOCS\Dropbox\Test\*.xml", True ' On copie le xml fraichement crée dans dropbox
else
Set f = oFSO.OpenTextFile("c:\ecr.txt", ForWriting,true)
f.writeline("Analysé le " + Now + ".")
end if
else
wshell.run "\\192.168.69.21\apps\absys\scriptocs.bat"
Wscript.Sleep(5000)
oFSO.CopyFile "C:\Documents and Settings\All Users\Application Data\OCS Inventory NG\Agent\*.xml", "\\192.168.69.21\apps\ABSYS\EXPORTSOCS\Dropbox\Test", True
end if
end if
end if |
Partager