VB Script to AutoConfigure Outlook

‘ VB Script to AutoConfigure Outlook

‘ Create a New Word Document

Set objWord = CreateObject(“Word.Application”)
objWord.Visible = True
Set objDoc = objWord.Documents.Add()
objWord.Quit(0) 
‘Close Word Document

‘Auto Configure Outlook
OnErrorResumeNext
strComputer = “.”
Set Shell = CreateObject(“Wscript.Shell”)
Set WshNetwork = WScript.CreateObject(“WScript.Network”)
Set FS = CreateObject(“Scripting.FilesystemObject”)
struser = WshNetwork.UserName

strprf = “C:\Users\” & struser & “\” & struser & “.prf”
strregkey=“HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Word\Options\PROGRAMDIR”‘ 11.0 - Office 2003, 12.0 - Office 2007, 14.0 Office 2010
strOlpath = chr(34) & Shell.RegRead(strregkey) & “outlook.exe” & chr(34)
Set Sfile = FS.OpenTextFile(strsrvprf, 1)
Set DFile = FS.OpenTextFile(strprf, 2, True)

‘ In next line search for MBX001 and replace with any one your Exchange Server Name, outlook automatically picks respective server based on User Logged in
            prfstr=“[General]”&vbcrlf&“Custom=1”&vbcrlf&“ProfileName=”&struser&vbcrlf&“DefaultProfile=Yes”&vbcrlf&“OverwriteProfile=Yes”&vbcrlf&“ModifyDefaultProfileIfPresent=TRUE”&vbcrlf&“DefaultStore=Service1”&vbcrlf&“[Service List]”&vbcrlf&“Service1=Microsoft Exchange Server”&vbcrlf&“ServiceEGS=Exchange Global Section”&vbcrlf&“[ServiceEGS]”&vbcrlf&“MailboxName=%UserName%”&vbcrlf&“HomeServer=MBX001”&vbcrlf&“[Service1]”&vbcrlf&“OverwriteExistingService=No”&vbcrlf&“UniqueService=Yes”&vbcrlf&“MailboxName=%UserName%”&vbcrlf&“HomeServer=MBX001”&vbcrlf&“AccountName=Microsoft Exchange Server”&vbcrlf& “[Microsoft Exchange Server]”&vbcrlf&“ServiceName=MSEMS”&vbcrlf&“MDBGUID=5494A1C0297F101BA58708002B2A2517”&vbcrlf&“MailboxName=PT_STRING8,0x6607”&vbcrlf&“HomeServer=PT_STRING8,0x6608”&vbcrlf&“[Exchange Global Section]”&vbcrlf&“SectionGUID=13dbb0c8aa05101a9bb000aa002fc45a”&vbcrlf&“MailboxName=PT_STRING8,0x6607”&vbcrlf&“HomeServer=PT_STRING8,0x6608”
DFile.WriteLine prfstr
Shell.Exec (strOlpath & “ /ImportPRF ” &  chr(34) & strprf & chr(34))
wscript.sleep (1500)
     

******************************* End of Script ***************************

Use the script @ your own risk.

!!! Happy Learning !!!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s