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 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
| Option Explicit
Dim MyDate
Dim ObjFile, FD, objtextfile
Dim objShell, WshShell, objmail
Dim Commande, CurrentDir, computername
Dim Tempo,
Dim Arbo, s
Dim objFSO, fso, oShell, oFSO,oFld
Dim Log
Dim FileLog
Dim Plaque1
Dim Plaque2
Dim Livraison_OS_Plaque1
Dim Livraison_OS1_Plaque2
Dim DESTINATAIRES
MyDate = Day(Now) & "." & Month(Now) & "." & Year(Now)
Log="H:\Livraison\Mig_Appli\Migration_Appli_" & MyDate & ".log"
Set fso = Wscript.CreateObject("Scripting.FileSystemObject")
Set FileLog = FSO.CreateTextFile(Log)
Plaque1 ="E:\Appli\projets\Plaque1"
Plaque2 ="E:\Appli\projets\Plaque2"
Livraison_OS_Plaque1 ="H:\Livraison\Mig_Appli\Plaque1"
Livraison_OS1_Plaque2 ="H:\Livraison\Mig_Appli\Plaque2"
DESTINATAIRES="pierre.dupont@société.fr"
Arbo="H:\Livraison\Mig_Appli"
'----------------------------------------------------
'Initialisation des log
'----------------------------------------------------
Sub Msglog(severite,code,label)
Wscript.echo Mydate & "-" & time & " " & severite & " " & code & " " & label
FileLog.WriteLine Mydate & "-" & time & " " & severite & " " & code & " " & label
End sub
'-----------------------------------------
'Arrêt des services Appli
'-----------------------------------------
Sub Arrete_Service(Nom_Service)
msglog "0","0000","---Debut: Arret service " & Nom_Service
set objShell = Wscript.CreateObject("Wscript.Shell")
Tempo=" """& Nom_Service &""" "
Commande="net stop" & Tempo
WscSipt.echo Commande
objShell.run(Commande)
Wscript.sleep 30000
msglog "0","0000","---Fin: Arret service " & Nom_Service
end sub
'-----------------------------------------------------------
'Sauvegarde du dossier Plaque1 en .old
'-----------------------------------------------------------
Sub Sauv_Plaque1
msglog "0","0000","---Debut: Sauvegarde du dossier " & Plaque1 & ".old"
Set fso = Wscript.CreateObject("Scripting.FileSystemObject")
Set FD = fso.GetFolder (Plaque1)
FD.Name = "Plaque1.old"
Set fso = Nothing
Set FD = Nothing
msglog "0","0000","---Fin: Sauvegarde du dossier " & Plaque1 & ".old"
End sub
'------------------------------------------------------------
'Sauvegarde du dossier Plaque2 en .old
'------------------------------------------------------------
Sub Sauv_Plaque2
msglog "0","0000","---Debut: Sauvegarde du dossier " & Plaque2 & ".old"
Set fso = Wscript.CreateObject("Scripting.FileSystemObject")
Set FD = fso.GetFolder (Plaque2)
FD.Name = "Plaque2.old"
Set fso = Nothing
Set FD = Nothing
msglog "0","0000","---Fin: Sauvegarde du dossier " & Plaque2 & ".old"
End sub
'-----------------------------------------------
'Création des dossiers Plaque1
'------------------------------------------------
Sub CreatFolderOS
msglog "0","0000","---Debut: Création des dossiers " & Plaque1 & ""
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFld=oFSO.OSeateFolder (Plaque1)
msglog "0","0000","---fin: Création des dossiers " & Plaque1 & ""
End sub
'-----------------------------------------------
'Création des dossiers Plaque2
'------------------------------------------------
Sub CreatFolderOS1
msglog "0","0000","---Debut: Création des dossiers " & Plaque2 & ""
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFld=oFSO.OSeateFolder (Plaque2)
msglog "0","0000","---fin: Création des dossiers " & Plaque2 & ""
End sub
'------------------------------------------------------------------------------------------------
'Copy des dossiers Livrés dans H:\Livraison >>>> Dossier Plaque1
'------------------------------------------------------------------------------------------------
Sub MigrPlaque_OS
msglog "0","0000","---Debut: Migration des dossiers et fichiers "
Set oFSO = CreateObject("Scripting.FileSystemObject")
oFSO.CopyFolder (Livraison_OS_Plaque1) , (Plaque1), True
msglog "0","0000","---Fin: Migration des dossiers et fichiers "
End sub
'------------------------------------------------------------------------------------------------
'Copy des dossiers Livrés dans H:\Livraison >>>> Dossier eCliDE90_secours
'------------------------------------------------------------------------------------------------
Sub MigrPlaque_OS1
msglog "0","0000","---Debut: Migration des dossiers et fichiers "
Set oFSO = CreateObject("Scripting.FileSystemObject")
oFSO.CopyFolder (Livraison_OS1_Plaque2) , (Plaque2), True
msglog "0","0000","---Fin: Migration des dossiers et fichiers "
End sub
'-----------------------------------------
' Demarrage des services Appli
'-----------------------------------------
Sub Demarre_Service(Nom_Service)
msglog "0","0000","---Debut: Demarrage service " & Nom_Service
set objShell = Wscript.CreateObject("Wscript.Shell")
Tempo=" """& Nom_Service &""" "
Commande="net start" & Tempo
Wscript.echo Commande
objShell.run(Commande)
Wscript.sleep 30000
msglog "0","0000","---Fin: Demarrage service " & Nom_Service
end sub
'-------------------------------------------------------------------------
'---- Envoi du log d'install par mail
'-----------------------------------------------------------------------------
Sub Envoi
msglog "0","0000","---Debut: Envoi de la log de Migration "
Set objMail = CreateObject("CDO.Message")
Set oFSO = CreateObject("Scripting.FileSystemObject")
With objMail
.Subject = "[Migration Appli] : Rapport de migration "
.From = "Migration Appli" & computername
.To = DESTINATAIRES
.TextBody = "Bonjour," & VbNewLine & VbNewLine & _
"Veuillez trouver ci-joint, le rapport de la migration Appli sur le serveur " & computername & VbNewLine & VbNewLine & _
"Cordialement," & VbNewLine & _
"Migration Appli." & VbNewLine & VbNewLine
.AddAttachment("H:\Livraison\Mig_Appli\Migration_Appli_" & MyDate & ".log")
End With
With objMail.Configuration.Fields
.Item("http://schemas.miOSosoft.com/cdo/configuration/smtpserver") = "mailhost.der.edf.fr"
.Item("http://schemas.miOSosoft.com/cdo/configuration/smtpserverport") = 25
.Item("http://schemas.miOSosoft.com/cdo/configuration/sendusing") = 2 'CDO.cdoSendUsingPort
.Update
End With
On Error Resume Next
objMail.Send
If Err.Number <>0 Then
msglog "1","0001","----Error Sending Mail"
Err.DesOSiption,16,"Error Sending Mail"
Else
msglog "0","0000","---Le Mail a été envoyé avec succès !"
End If
End Sub
set s = CreateObject("Wscript.Shell")
s.currentdirectory = Arbo
set s = nothing
'---------------------------
' Corps su script
'---------------------------
msglog "0","0000","---Debut: Migration_Appli.vbs "
Arrete_Service "Appli zip_OS"
Arrete_Service "Appli PostProd_OS"
Arrete_Service "Appli MailBDT_OS"
Arrete_Service "Appli HTTP"
Arrete_Service "Appli BATCH"
Arrete_Service "Appli Calcul_OS"
Arrete_Service "Appli Repository Server"
Sauv_Plaque1
Sauv_Plaque2
CreatFolderOS
CreatFolderOS1
MigrPlaque_OS
MigrPlaque_OS1
Demarre_Service "Appli Repository Server"
Demarre_Service "Appli Calcul_OS"
Demarre_Service "Appli batch_ZC"
Demarre_Service "Appli HTTP_"
Demarre_Service "Appli MailBDT_OS"
Demarre_Service "Appli PostProd_OS"
Demarre_Service "Appli zip_OS"
msglog "0","0000","---Fin: Migration_Appli"
msglog "0","0000","---Fin: Migration_Appli.vbs "
FileLog.Close
Envoi |
Partager