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
| Dim oFSO, fichierVbs, oF1, oF2
Sub Run(ByVal sFile)
Dim shell
Set shell = CreateObject("WScript.Shell")
shell.Run Chr(34) & sFile & Chr(34), 1, false
Set shell = Nothing
End Sub
Set oFSO = CreateObject("Scripting.FilesystemObject")
fichierXml = "C:\Documents and Settings\All Users\Application Data\OCS Inventory NG\Agent\*.xml"
if oFSO.FileExists(fichierVbs) then
Set oF1 = oFSO.GetFile(fichierVbs) ' 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:\Documents and Settings\All Users\Application Data\OCS Inventory NG\Agent*.xml",True
oFSFO.DeleteFile "C:\Dropbox\Test"
Run "\\192.168.69.21\NETLOGON\ocspackage.exe"
oFSO.CopyFile "C:\Documents and Settings\All Users\Application Data\OCS Inventory NG\Agent\*.xml", "C:\DropBox\Test", True
else
set oF2 = oFSO.CreateFolder ("C:\Dropbox\Test")
oFSO.CopyFile "C:\Documents and Settings\All Users\Application Data\OCS Inventory NG\Agent\*.xml", "C:\Dropbox\Test", True' et je le copie
end if
else
Run "\\192.168.69.21\NETLOGON\ocspackage.exe"
set oF2 = oFSO.CreateFolder ("C:\Dropbox\Test")
oFSO.CopyFile "C:\Documents and Settings\All Users\Application Data\OCS Inventory NG\Agent\*.xml", "C:\DropBox\Test", True
end if |
Partager