option explicit
on error resume next
'*************************************************************************
'***** VARIABLES TO CHANGE - MIMECAST SERVICE HOSTNAMES and PASSWORD *****
'*************************************************************************
dim strMCserv1, strMCserv2, pwd
strMCserv1 = "service1.mimecast-offshore.com"
strMCserv2 = "service2.mimecast-offshore.com"
pwd = "*********"
'************************************
'***** Declare variables to use *****
'************************************
dim objNetwork, strUser, strDomain, mailAdr, logstream
'variables to create path to dpeloymimecast.exe
Dim sPath, sPath2, sPath3
'variables for outlook connector config - service hostnames, password
Dim sCom
'variables for use in script - WHSShell and log file creation
Dim objFSO1, WSHShell, strTempDirectory, strFile, objFolder, objFile
'set system object variables
Set objFSO1 = CreateObject("Scripting.FileSystemObject")
Set WSHShell = CreateObject("WScript.Shell")
'Determine Path to temp directory
strTempDirectory = WSHShell.Environment("Process")("HOMEDRIVE")
'strTempDirectory = "C\temp"
strFile = "\temp\DeployMimecastLog.txt"
sCom = """"
OpenLog ("DeployMimecastErrorLog.txt")
'************************************
'***** Get username and address *****
'************************************
Err.clear
Set objNetwork = CreateObject("Wscript.Network")
strUser = objNetwork.UserName
LogError strUSer, err.number, err.description
if err.number <> 0 then
LogError "GetUserName", err.number, err.description
end If
Err.clear
strDomain = objNetwork.UserDomain
LogError strDomain, err.number, err.description
if err.number <> 0 then
LogError "GetUSerDomain", err.number, err.description
end If
Err.clear
mailAdr = GetEmail(strUser, strDomain)
LogError mailAdr, err.number, err.description
if err.number <> 0 then
LogError "CallGetEmailFunction", err.number, err.description
end if
'*****************************************************
'*** DETERMINE PATH TO THE DEPLOYMIMECAST.EXE FILE ***
'*****************************************************
Err.clear
'check for "Program Files (x86)" first using environment variables
'sPath = WSHShell.environment("Process")("Program Files (x86)")
sPath = "C:\Program Files (x86)"
'If we cannot find the path to "Program Files (x86)" using
'environment variables then read registry to obtain info
If sPath = "" Then
sPath = WSHShell.RegRead ("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\ProgramFilesDir")
End If
LogError sPath, err.number, err.description
if err.number <> 0 then
LogError "GetProgramFiles", err.number, err.description
sPath = ""
end if
'adding the "Mimecast" path to "Program Files (x86)" - DeployMimecast.exe
'sPath2 becomes the path to DeeployMimecast.exe on the local machine
'THIS ASSUMES THAT THE CONNECTOR HAS BEEN INSTALLED TO THE DEFAULT DIRECTORY
Err.clear
sPath2 = sPath + "\Mimecast\Mimecast Services for Outlook\deploymimecast.exe"
LogError sPath2, err.number, err.description
if err.number <> 0 then
LogError "GetMimecastDir", err.number, err.description
sPath2 = ""
end if
'add parameters after deploymimecast.exe - config for the Outlook connector
Err.clear
'****************************************************************************************
'****** Command used for AD username and no password - end user will enter password *****
'****************************************************************************************
'sPath3 = sCom & sPath2 & sCom & Space(1) & sCom & mailAdr & sCom & Space(1) & sCom & strUser & sCom & _
' Space(1) & sCom & sCom & Space(1) & sCom & strMCserv1 & sCom & _
' Space(1) & sCom & strMCserv2 & sCom
'*********************************************************************************
'****** Command used for all local Mimecast logins - no end user interaction *****
'*********************************************************************************
sPath3 = sCom & sPath2 & sCom & Space(1) & sCom & mailAdr & sCom & Space(1) & sCom & sCom & _
Space(1) & sCom & pwd & sCom & Space(1) & sCom & strMCserv1 & sCom & _
Space(1) & sCom & strMCserv2 & sCom
LogError sPath3, err.number, err.description
if err.number <> 0 then
LogError "BuildMimecastPath", err.number, err.description
end if
'**************************************************
'*** EXECUTE DEPLOYMIMECAST.EXE WITH PARAMETERS ***
'**************************************************
'execute deploymimecast.exe with all parameters and write ouput to log file
'WSHShell.exec (sPath3)
Dim objShell,objStdOut,strOutput,objTextFile, regAutoUpdate
Const ForAppending = 8
Set objFSO1 = CreateObject("Scripting.FileSystemObject")
Err.clear
Set logstream = objFSO1.OpenTextFile(strTempDirectory & strFile, ForAppending, True)
if err.number <> 0 then
LogError "OpenTextFile", err.number, err.description
logstream = ""
end if
Err.clear
Set objShell = WSHShell.exec (sPath3)
if err.number <> 0 then
LogError "ExecMimecast", err.number, err.description
objShell = ""
end if
Set objStdOut = objShell.StdOut
strOutput = objStdOut.ReadAll
logstream.writeline ("*************************************************************************")
logstream.writeline Now()
logstream.writeline ("*************************************************************************")
logstream.writeline strOutput
logStream.Close
'WriteLogEntry("this is a test")
Err.clear
'*************************************************************
'*** EDIT REGISTRY ENTRIES TO MANIPULATE DEFAULT STETTINGS ***
'*************************************************************
'set registry to enable/disable auto updates - change true/false
regAutoUpdate = WSHShell.RegRead ("HKCU\SOFTWARE\Mimecast\Mimecast Online\Enable Automatic Updates")
If regAutoUpdate = "true" THEN
regAutoUpdate = WSHShell.RegWrite ("HKCU\SOFTWARE\Mimecast\Mimecast Online\Enable Automatic Updates", "false", "REG_SZ")
End If
'set registry to enable/disable auto failover to Mimecast - change true/false
'regAutoFailover = WSHShell.RegWrite ("HKCU\SOFTWARE\Mimecast\Mimecast Online\EnableAutoFailOver", _
' "true", "REG_SZ")
if err.number <> 0 then
LogError "RegistryWrite", err.number, err.description
end if
CloseLog
'**************************************************
'*** get users email address from name & domain ***
'**************************************************
Function GetEmail(strAccountName, strDomainName)
err.clear
Dim adoLDAPCon,adoLDAPRS,strLDAP
Set adoLDAPCon = CreateObject("ADODB.Connection")
adoLDAPCon.Provider = "ADsDSOObject"
adoLDAPCon.Open "ADSI"
strLDAP = "'LDAP://" & strDomainName & "'"
Set adoLDAPRS = adoLDAPCon.Execute("select mail from " & strLDAP & " WHERE objectClass = 'user'"& " And samAccountName = '" & strAccountName & "'")
With adoLDAPRS
If Not .EOF Then
GetEmail = .Fields("mail")
Else
GetEmail = ""
End If
End With
adoLDAPRS.Close
if err.number <> 0 then
LogError "GetEmail", err.number, err.description
GetEmail = ""
end if
Set adoLDAPRS = Nothing
Set adoLDAPCon = Nothing
End Function
'**************************
'*** logging functions ***
'**************************
sub OpenLog (logfile)
dim fso
set fso = createobject("scripting.filesystemobject")
set logstream = fso.opentextfile("c:\temp\" & logfile, 8, true)
end sub
sub LogError (location, number, description)
logstream.writeline now() & ": " & "[" & location & "] (" & number & ") " & description
end sub
sub CloseLog
logstream.close
end sub
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:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
by: itkamarajPosted on 2009-03-02 at 06:57:33ID: 23774459
run silently
e.com/Soft ware/OS-2_ Apps/ Q_236 93651.html
http://www.experts-exchang