BREAK ON
CLS
outlook
FUNCTION OUTLOOK()
DIM $prfrem,$waste,$editorpref,$prf,$serverloc,
$exchgsvr,$prfloc,$prffile,$ppru,$exe,$ver,$idx,$keyname,$rc,
$outlook,$ns,$unread,$fldr,$x,$regexp,$MSOdir
$waste='FALSE' ; If set to TRUE, Empty Outlooks Deleted Items Folder on Exit
$editorpref=30001 ; Editor Preference 10001=Plain Text, 20001=HTML, and 30001=Rich Text
$prf='Outlook.prf'
$prffile='%temp%\'+$prf
$serverloc=@LSERVER+'\NETLOGON\' ; Outlook .PRF location
$exchgsvr='BRA01' ; Main Exchange Server Location
$prfloc='HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles'
; -- Current User Profile
$ppru=$prfloc+'\'+@USERID
; -- Determine version of Outlook
$exe=ReadValue('HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE','')
$ver=SPLIT(GetFileVersion($exe),'.')[0]+'.0'
; -- Determine location of Office
$MSOdir=SUBSTR($exe,1,Len($exe)-11)
; -- This is used for when you have people come into the company from another Exchange Server into yours
; -- This is an Optional section
;IF INGROUP('GROUPNAME') AND READVALUE($ppru+'\13dbb0c8aa05101a9bb000aa002fc45a','001e6602')<>$exchgsvr
; $rc=WriteValue($ppru+'\13dbb0c8aa05101a9bb000aa002fc45a','001e6602',$exchgsvr,'REG_SZ')
; $rc=WriteValue($ppru+'\13dbb0c8aa05101a9bb000aa002fc45a','001e6608',$exchgsvr,'REG_SZ')
;ENDIF
; -- Look for Outlook Profile
IF (ReadValue($prfloc,'DefaultProfile')<>@USERID AND NOT INSTR(ReadValue($prfloc,'DefaultProfile'),'MS Exchange')) OR @ERROR
COPY $serverloc+'\'+$prf $prffile
; $rc=WriteProfileString($prffile,'General','ProfileName',@USERID)
; $rc=WriteProfileString($prffile,'General','DefaultProfile','Yes')
; $rc=WriteProfileString($prffile,'General','OverwriteProfile','Yes')
; $rc=WriteProfileString($prffile,'General','BackupProfile','No')
; $rc=WriteProfileString($prffile,'Service1','AutoNameCheck','TRUE')
; $rc=WriteProfileString($prffile,'Service1','EmptyWastebasket',$waste)
; $rc=WriteProfileString($prffile,'Service1','CloseOriginalMessage','TRUE')
; $rc=WriteProfileString($prffile,'Service2','HomeServer',$exchgsvr)
; $rc=WriteProfileString($prffile,'Service2','MailboxName',@USERID)
;-- If you are running a generated profile, you may not need these entries
; $rc=WriteProfileString($prffile,'Service1','MailboxName',@USERID)
; $rc=WriteProfileString($prffile,'ServiceEGS','MailboxName',@USERID)
; $rc=WriteProfileString($prffile,'ServiceEGS','HomeServer',$exchgsvr)
;If Needed, you may want to uncomment the next line
;$ver='10.0' OR $ver='11.0' OR $ver='12.0';(e.g. 10.0.2627.1)
$rc=DelValue('HKCU\Software\Microsoft\Office\'+$ver+'\Outlook\Setup','First-Run')
$rc=WriteValue('HKCU\Software\Microsoft\Office\'+$ver+'\Outlook\Setup','ImportPRF',$prffile,'REG_SZ')
IF $ver='10.0'
$rc=WriteValue('HKCU\Software\Microsoft\Office\'+$ver+'\Outlook\IM','Enabled',0,'REG_DWORD')
ENDIF
$rc=WriteValue('HKCU\Software\Microsoft\Office\Common','QMEnable',0,'REG_DWORD') ; -- Turn off User Feedback
; -- This was added as we needed to generate Outlook Profiles in a Citrix Session - thanks Rad!
$outlook=CreateObject('Outlook.Application')
$ns=$outlook.getnamespace('MAPI')
$fldr=$ns.getdefaultfolder(6)
$unread=$fldr.unreaditemcount
$outlook=0
DEL $MSOdir+'welcome.msg' ; -- Delete welcome message
ENDIF
ENDFUNCTION