git-svn-id: http://locode01.ad.dom/svn/WEBMIP/trunk@5456 248e525c-4dfb-0310-94bc-949c084e9493
72 lines
2.2 KiB
Plaintext
72 lines
2.2 KiB
Plaintext
REM $Id$
|
|
const scripts_src = "\\advwb1\scripts"
|
|
const logship_user = "advweb\logship"
|
|
const logship_pwd = "logship"
|
|
const strFrom = "webmip@AdvanticaGroup.com"
|
|
const strTo = "Andrew.Hardy@AdvanticaGroup.com"
|
|
const strSub = "MIP: ApplyLog"
|
|
const strSubError = "MIP: ApplyLog Error"
|
|
strBody = "ApplyLog Completed Successfully"
|
|
const strSMTP = "relay01.sleek.net"
|
|
|
|
|
|
ShowApplyLog scripts_src, logship_user, logship_pwd
|
|
|
|
|
|
Sub ShowApplyLog(strDest, strUser, strPwd)
|
|
Dim strAttachment
|
|
strAttachment = "X:\applylog.log"
|
|
|
|
Dim strRemoteDrive
|
|
strRemoteDrive = "X:"
|
|
|
|
'error handling
|
|
On Error Resume Next
|
|
|
|
Set objNetwork = CreateObject("WScript.Network")
|
|
|
|
objNetwork.MapNetworkDrive strRemoteDrive, strDest, false, strUser, strPwd
|
|
|
|
'handle error
|
|
If Err.Number <> 0 Then
|
|
SendEmail strFrom, StrTo, strSubError, "Error Mapping " & strDest & ":" & Err.Description, StrSMTP
|
|
Wscript.Echo "Error number " & Err.Number & " occured: " & Err.Description
|
|
Wscript.Echo ""
|
|
Wscript.Quit Err.Number
|
|
End If
|
|
|
|
SendEmail strFrom, StrTo, strSub, strBody, StrSMTP, strAttachment
|
|
|
|
objNetwork.RemoveNetworkDrive strRemoteDrive
|
|
'handle error
|
|
If Err.Number <> 0 Then
|
|
SendEmail strFrom, StrTo, strSubError, "Error Removing Remote Folder " & strRemoteDrive & ":" & Err.Description, StrSMTP
|
|
Wscript.Echo "Error number " & Err.Number & " occured: " & Err.Description
|
|
Wscript.Echo ""
|
|
Wscript.Quit Err.Number
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
' From the book "Windows Server Cookbook" by Robbie Allen
|
|
' ISBN: 0-596-00633-0
|
|
|
|
Sub SendEmail(strFrom, StrTo, strSub, strBody, StrSMTP, strAttachment)
|
|
set objEmail = CreateObject("CDO.Message")
|
|
objEmail.From = strFrom
|
|
objEmail.To = strTo
|
|
objEmail.Subject = strSub
|
|
objEmail.Textbody = strBody
|
|
objEmail.AddAttachment strAttachment
|
|
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
|
|
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTP
|
|
objEmail.Configuration.Fields.Update
|
|
objEmail.Send
|
|
If Err.Number <> 0 Then
|
|
Wscript.Echo "Error number " & Err.Number & " occured: " & Err.Description
|
|
Wscript.Echo ""
|
|
Wscript.Quit Err.Number
|
|
End If
|
|
WScript.Echo "Email sent"
|
|
End Sub |