Tuesday, August 9, 2011

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 !!!

Telnet Client Windows 7


Today I got a requirement from our Network Support Team. As part of their day - day activities, they need to troubleshoot network related issues by using Telnet.

But one of my colleagues didn't find telnet in Windows 7 system. He was upset as the telnet client is not installed by default and asked me to apply some GPO to enable the same.

Instead of configuring a GPO, below command can be executed by a batch file, psexec, startup/logon script.

pkgmgr /iu:"TelnetClient"

~~~Happy Learning~~~