[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.4

VBScript - hide command prompt window and AD query

Asked by andyjarvis in VB Script

Hi

I have been given a script that creates an additional email folder in Outlook when users log on. The script works fine. When a user logs on and the script runs, it displays a command prompt window.

Where and what do I put in the script that hides the command prompt window from appearing?
I also want the script to run for users in a certain AD security group. How can this be done.

Any help would be greatly appreciated.

Thanks


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:
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
[+][-]03/02/09 06:57 AM, ID: 23774459Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: VB Script
Sign Up Now!
Solution Provided By: itkamaraj
Participating Experts: 1
Solution Grade: B
 
 
Loading Advertisement...
20091111-EE-VQP-89 - Hierarchy / EE_QW_3_20080625