VBScript - hide command prompt window and AD query
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
option expliciton error resume next'*************************************************************************'***** VARIABLES TO CHANGE - MIMECAST SERVICE HOSTNAMES and PASSWORD *****'*************************************************************************dim strMCserv1, strMCserv2, pwdstrMCserv1 = "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.exeDim sPath, sPath2, sPath3'variables for outlook connector config - service hostnames, passwordDim sCom'variables for use in script - WHSShell and log file creationDim objFSO1, WSHShell, strTempDirectory, strFile, objFolder, objFile 'set system object variables Set objFSO1 = CreateObject("Scripting.FileSystemObject")Set WSHShell = CreateObject("WScript.Shell")'Determine Path to temp directorystrTempDirectory = WSHShell.Environment("Process")("HOMEDRIVE")'strTempDirectory = "C\temp"strFile = "\temp\DeployMimecastLog.txt"sCom = """"OpenLog ("DeployMimecastErrorLog.txt")'************************************'***** Get username and address *****'************************************ Err.clearSet objNetwork = CreateObject("Wscript.Network")strUser = objNetwork.UserNameLogError strUSer, err.number, err.description if err.number <> 0 then LogError "GetUserName", err.number, err.description end IfErr.clearstrDomain = objNetwork.UserDomainLogError strDomain, err.number, err.description if err.number <> 0 then LogError "GetUSerDomain", err.number, err.description end IfErr.clearmailAdr = 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 infoIf 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.clearsPath2 = 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 & sComLogError 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, regAutoUpdateConst ForAppending = 8Set objFSO1 = CreateObject("Scripting.FileSystemObject")Err.clearSet logstream = objFSO1.OpenTextFile(strTempDirectory & strFile, ForAppending, True) if err.number <> 0 then LogError "OpenTextFile", err.number, err.description logstream = "" end ifErr.clearSet objShell = WSHShell.exec (sPath3) if err.number <> 0 then LogError "ExecMimecast", err.number, err.description objShell = "" end ifSet objStdOut = objShell.StdOutstrOutput = objStdOut.ReadAlllogstream.writeline ("*************************************************************************")logstream.writeline Now()logstream.writeline ("*************************************************************************")logstream.writeline strOutputlogStream.Close'WriteLogEntry("this is a test")Err.clear'*************************************************************'*** EDIT REGISTRY ENTRIES TO MANIPULATE DEFAULT STETTINGS ***'*************************************************************'set registry to enable/disable auto updates - change true/falseregAutoUpdate = 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 ifCloseLog'**************************************************'*** 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 = NothingEnd Function'**************************'*** logging functions ***'**************************sub OpenLog (logfile) dim fso set fso = createobject("scripting.filesystemobject") set logstream = fso.opentextfile("c:\temp\" & logfile, 8, true)end subsub LogError (location, number, description) logstream.writeline now() & ": " & "[" & location & "] (" & number & ") " & descriptionend subsub CloseLog logstream.closeend sub
Andy,
I am running the MSO for outlook also. I have it sortd for a Citrix environmnet but I am having issues with the desktop side. Woudl you share the script you have customized for using with the desktops in your company please? We are running the beta 3.2 in our farm but are waiting for the new release.
Regards Paul