Page 1 of 1 1
Topic Options
#120065 - 2004-05-24 10:02 PM RFC: Outlook Configuration Script
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Been working on a new version of this script and feel that this is coming together. It is an update to the Outlook FAQ. Any comments are welcome.

OUTLOOK.INI > Outlook Configuration Information
Code:

[OUTLOOK]
profile_remove='Yes'
deleteitems='Yes'
explorview='Yes'
editorpref='30001'
prf='Outlook.prf'
company='YourCompany, Inc.'
serverloc=%logonserver%\Netlogon\Profgen\Outlook2000
exchangeserver='YOUREXCHANGESERVER'

[]
;CHANGE THE [] TO [OUTLOOK] to use
profile_remove='Yes' ; Remove All other Outlook profiles under current user
deleteitems='Yes'; Empty Outlooks Deleted Items Folder on Exit
explorview='Yes' ; Outlook Explorer View 'Yes' or Standard View 'No'
editorpref='30001' ; Editor Preference 10001=Plain Text, 20001=HTML, and 30001=Rich Text
prf='Outlook.prf'
company='Your Company, Inc.'
serverloc=%logonserver%\Netlogon\Profgen\Outlook2000' ; Outlook Executables files location on the logon server
exchangeserver='YOUREXCHANGSERVER' ; Main Exchange Server Location



Main Outlook Configuration script:
Code:

;cls
;break on
DIM $olini,$prfrem,$delitem,$expvw,$editprf,$prf,$company,$server,
$serverloc,$exchangeserver,$ushefolders,$userwinkey,$machinewinkey,
$ofc,$mofckey,$uofckey,$profilelocation,$scriptdir,$prffile,
$ppru,$mses,$exe,$vers,$vchk,$index,$keyname
; -- SET VARIABLES > CHECK THE INI FOR COMMENTS
$olini=@scriptdir+'\outlook.ini'
$prfrem=READPROFILESTRING($olini,'OUTLOOK','profile_remove')
$delitem=READPROFILESTRING($olini,'OUTLOOK','deleteitems')
$expvw=READPROFILESTRING($olini,'OUTLOOK','explorview')
$editprf=READPROFILESTRING($olini,'OUTLOOK','editorpref')
$prf=READPROFILESTRING($olini,'OUTLOOK','prf')
$company=READPROFILESTRING($olini,'OUTLOOK','company')
$serverloc=EXPANDENVIRONMENTVARS(READPROFILESTRING($olini,'OUTLOOK','serverloc'))
$exchangeserver=READPROFILESTRING($olini,'OUTLOOK','exchangeserver')
; -- SET REGISTRY KEYS
$userwinkey='HKCU\Software\Microsoft\Windows'
$ushefolders=$userwinkey+'\CurrentVersion\Explorer\Shell Folders'
$machinewinkey='HKLM\Software\Microsoft\Windows'
$ofc='\Software\Microsoft\Office\'
$mofckey='HKLM'+$ofc
$uofckey='HKCU'+$ofc
; -- CHECK WHERE THE PROFILE IS LOCATED
IF @inwin=1
;Windows NT/2k/XP/2003
$profilelocation=$userwinkey+' NT\CurrentVersion\Windows Messaging Subsystem\Profiles'
ELSE
;Windows 9x
$profilelocation=$userwinkey+' Messaging Subsystem\Profiles'
ENDIF
$scriptdir=SPLIT('%WINDIR%',':')[0]+':\Scripts'
IF 0=EXIST($scriptdir)
MD $scriptdir
ENDIF
$prffile='%temp%\'+$prf
;$ppru=$profilelocation+'\'+@userid
;$mses=$profilelocation+'\MS Exchange Settings'
$pp=READVALUE($profilelocation,'DefaultProfile')
$vchk=SPLIT(GETFILEVERSION(READVALUE($machinewinkey+'\CurrentVersion\App Paths\OUTLOOK.EXE','')),'.')[0]
MSUSERINFO($company,$uofckey,$vchk)
IF INGROUP('CompanyToMigrate')
; -- MIGRATE THE USER FROM THE OLD SERVER
MIGRATEMAIL($ppru,$scriptdir,$serverloc,$exchangeserver)
ENDIF
;IF 0=KEYEXIST($mses) AND 0=KEYEXIST($ppru)
IF 0=KEYEXIST($profilelocation+'\'+$pp)
COPY $serverloc+'\'+$prf '%temp%\'+$prf
; -- CHECK THE PRF FILE
PRFSETTINGS($prffile,$exchangeserver,$delitem)
; -- REMOVE EXTRA PROFILES FROM OUTLOOK
IF $prfrem='YES'
$index=0
$keyname=ENUMKEY($profilelocation,$index)
WHILE @error=0
IF $keyname<>@userid $rc=DELTREE($profilelocation+'\'+$keyname)
ENDIF
$index=$index+1
$keyname=ENUMKEY($profilelocation,$index)
LOOP
ENDIF
SELECT ; -- NOW, CHECK TO SEE WHAT VERSION OF OUTLOOK THEY ARE RUNNING
CASE
$vchk=8 OR $vchk=9 ;(e.g. 8.5.5104.0 OR 9.0.0.2416))
OUTLOOK8AND9($vchk+'.'+0,$scriptdir,$mofckey,$uofckey,$profilelocation,$prffile,$expvw,$serverloc)
CASE
$vchk=10 OR $vchk=11;(e.g. 10.0.2627.1 OR 11.0.5329.6))
OUTLOOK10AND11($vchk+'.'+0,$uofckey,$prffile,$expvw)
ENDSELECT
ENDIF
FUNCTION PRFSETTINGS($prffile,$exchangeserver,$delitem)
DIM $rc,$g,$s1,$s2,$header
; Custom Profile Settings
FOR EACH $g IN SPLIT('ProfileName @userid,DefaultProfile Yes,
OverwriteProfile Yes,BackupProfile No',',')
$g=SPLIT($g)
IF $g[1]<>READPROFILESTRING($prffile,'General',$g[0])
$rc=WRITEPROFILESTRING($prffile,'General',$g[0],$g[1])
ENDIF
NEXT
FOR EACH $s1 IN SPLIT('AutoNameCheck TRUE,ConfirmOnDelete FALSE,
RemoveSchdPlus FALSE,SelectEntireWord TRUE,
CloseOriginalMessage TRUE,GenReadReceipt FALSE,
GenDeliveryReceipt FALSE,SaveSentMail TRUE',',')
$s1=SPLIT($s1)
IF $s1[1]<>READPROFILESTRING($prffile,'Service1',$s1[0])
$rc=WRITEPROFILESTRING($prffile,'Service1',$s1[0],$s1[1])
ENDIF
NEXT
IF $delitem='YES'
IF 'TRUE'<>READPROFILESTRING($prffile,'Service1','EmptyWastebasket')
$rc=WRITEPROFILESTRING($prffile,'Service1','EmptyWastebasket','TRUE')
ENDIF
ELSE
IF 'FALSE'<>READPROFILESTRING($prffile,'Service1','EmptyWastebasket')
$rc=WRITEPROFILESTRING($prffile,'Service1','EmptyWastebasket','FALSE')
ENDIF
ENDIF
FOR EACH $s2 IN SPLIT('HomeServer '+$exchangeserver+',MailboxName @userid',',')
$header='Service2'
$s2=SPLIT($s2)
IF $s2[1]<>READPROFILESTRING($prffile,$header,$s2[0])
$rc=WRITEPROFILESTRING($prffile,$header,$s2[0],$s2[1])
ENDIF
NEXT
ENDFUNCTION
FUNCTION OUTLOOK8AND9($vers,$scriptdir,$mofckey,$uofckey,$profilelocation,$prffile,$expvw,$serverloc)
DIM $rc,$expview,$fl
FOR EACH $fl IN SPLIT('Profgen.exe NEWPROF.EXE')
IF 0=EXIST($scriptdir+'\'+$fl)
COPY $serverloc+'\'$fl $scriptdir
ENDIF
NEXT
IF @inwin=1
SHELL '%COMSPEC% /C '+$scriptdir+'\Profgen.exe '+$scriptdir+'\Newprof.exe -p '+$prffile+' -X -R -L > nul'
ELSE
SHELL '%COMSPEC% /C '+$scriptdir+'\Newprof.exe -p '+$scriptdir+' -X -R -L > nul'
ENDIF
SLEEP 1
IF $expvw='Yes'
IF 0=KEYEXIST($mofckey+$vers)
$rc=ADDKEY($mofckey+$vers)
ENDIF
IF 0=KEYEXIST($uofckey+$vers)
$rc=ADDKEY($uofckey+$vers)
ENDIF
IF 0=KEYEXIST($mofckey+$vers+'\Common')
$rc=ADDKEY($mofckey+$vers+'\Common')
ENDIF
IF 0=KEYEXIST($uofckey+$vers+'\Common')
$rc=ADDKEY($uofckey+$vers+'\Common')
ENDIF
IF 0=KEYEXIST($uofckey+$vers+'\Preferences')
$rc=ADDKEY($uofckey+$vers+'\Preferences')
ENDIF
IF 0=KEYEXIST($uofckey+$vers+'\Common\UserInfo')
$rc=ADDKEY($uofckey+$vers+'\Common\UserInfo')
ENDIF
IF 0=KEYEXIST($mofckey+'Outlook')
$rc=ADDKEY($mofckey+'Outlook')
ENDIF
IF 0=KEYEXIST($uofckey+$vers+'\Outlook\Options')
$rc=ADDKEY($uofckey+$vers+'\Outlook\Options')
ENDIF
IF 0=KEYEXIST($uofckey+$vers+'\Outlook\Options\Mail')
$rc=ADDKEY($uofckey+$vers+'\Outlook\Options\Mail')
ENDIF
IF 0=KEYEXIST($mofckey+$vers+'\Outlook\Setup')
$rc=ADDKEY($mofckey+$vers+'\Outlook\Setup')
ENDIF
IF 0=KEYEXIST($uofckey+$vers+'\Outlook\Office Explorer')
$rc=ADDKEY($uofckey+$vers+'\Outlook\Office Explorer')
ENDIF
IF @wksta<>READVALUE($uofckey+$vers+'\Outlook','Machine Name')
$rc=WRITEVALUE($uofckey+$vers+'\Outlook','Machine Name',@wksta,'REG_SZ')
ENDIF
IF 1<>READVALUE($uofckey+$vers+'\Outlook','CheckInternetAccounts')
$rc=WRITEVALUE($uofckey+$vers+'\Outlook','CheckInternetAccounts','1','REG_DWORD')
ENDIF
IF 'False'<>READVALUE($uofckey+$vers+'\Outlook','FirstRunDialog')
$rc=WRITEVALUE($uofckey+$vers+'\Outlook','FirstRunDialog','False','REG_SZ')
ENDIF
IF 1<>READVALUE($uofckey+$vers+'\Outlook\Setup','PrimaryClient')
$rc=WRITEVALUE($uofckey+$vers+'\Outlook\Setup','PrimaryClient','1','REG_DWORD')
ENDIF
IF 1<>READVALUE($mofckey+$vers+'\Outlook\Setup','MailSupport')
$rc=WRITEVALUE($mofckey+$vers+'\Outlook\Setup','MailSupport','1','REG_DWORD')
ENDIF
IF 1<>READVALUE($mofckey+$vers+'\Outlook\Setup','First-Run')
$rc=WRITEVALUE($mofckey+$vers+'\Outlook\Setup','First-Run','df83b12adc9cd511b57c0002a57ce19c','REG_BINARY')
ENDIF
;If '196610'<>READVALUE($uofckey+$vers+'\Outlook\Options\Mail','EditorPreference')
; $rc=WRITEVALUE($uofckey+$vers+'\Outlook\Options\Mail','EditorPreference','196610','REG_DWORD')
;EndIf
$rc=WRITEVALUE($profilelocation+@userid+'\0a0d020000000000c000000000000046','001e0360','','REG_SZ')
$expview='010000002c0000000200000003000000ffffffffffffffffffffffffffffffff62000000270000003'
$expview=$expview+'c030000ac02000001000000000000000100000000000000c00000006400000003000000'
$rc=WRITEVALUE('HKCU\Software\Microsoft\Office\'+$vers+'\Outlook\Office Explorer','Frame',$expview,'REG_BINARY')
;$pltextfont='3c0000000f0000e800000040c80000000600000000000000002056657264616e6100020000000000000000'
;$pltextfont=$pltextfont+'0000000000201a493a38e9070001000000'
;$rc=WRITEVALUE($uofckey+$vers+'\Outlook\Preferences','PlainTextFont',$pltextfont,'REG_BINARY')
ENDIF
ENDFUNCTION
FUNCTION OUTLOOK10AND11($vers,$uofckey,$prffile,$expvw)
DIM $expview,$rc
$rc=DELVALUE($uofckey+$vers+'\Outlook\Setup','First-Run')
$rc=WRITEVALUE($uofckey+$vers+'\Outlook\Setup','ImportPRF',$prffile,'REG_SZ')
SLEEP 1
;If '196610'<>READVALUE($uofckey+$vers+'\Outlook\Options\Mail','EditorPreference')
; $rc=WRITEVALUE($uofckey+$vers+'\Outlook\Options\Mail','EditorPreference','196610','REG_DWORD')
;EndIf
;$pltextfont='3c0000000f0000e800000040c80000000600000000000000002056657264616e6100020000000000000000'
;$pltextfont=$pltextfont+'0000000000201a493a38e9070001000000'
;$rc=WRITEVALUE($uofckey+$vers+'\Outlook\Preferences','TextFontSimple',$pltextfont,'REG_BINARY')
IF $expvw='Yes' AND $vers='10.0'
$expview='010000002c0000000200000003000000ffffffffffffffffffffffffffffffff2c0000002c00000084'
$expview=$expview+'020000dc01000001000000000000000100000000000000c0000000640000001800000003000000'
$rc=WRITEVALUE($uofckey+$vers+'\Outlook\Office Explorer','Frame',$expview,'REG_BINARY')
ENDIF
; -- DISABLE MSN MESSENGER FOR OUTLOOK XP
IF $vers='10.0'
$rc=ADDKEY($uofckey+$vers+'\Outlook\IM')
$rc=WRITEVALUE($uofckey+$vers+'\Outlook\IM','Enabled',0,'REG_DWORD')
ENDIF
ENDFUNCTION
FUNCTION MSUSERINFO($company,$uofckey,$vchk)
DIM $x,$regexp,$companybin,$fullnamebin,$useridbin,$initials,$regkey,$rc
IF KEYEXIST('HKCU\Software\Microsoft\Office')
; Process Company Name
$x=1
$regexp=''
WHILE $x<(LEN($company)+1)
$regexp=$regexp+DECTOHEX(ASC(SUBSTR($company,$x,1)))+'00'
$x=$x+1
LOOP
$regexp=$regexp+'0000'
$companybin=$regexp
; Process FullName
$x=1
$regexp=''
WHILE $x<(LEN(@fullname)+1)
$regexp=$regexp+DECTOHEX(ASC(SUBSTR(@fullname,$x,1)))+'00'
$x=$x+1
LOOP
$regexp=$regexp+'0000'
$fullnamebin=$regexp
; Process UserID
$useridbin=SUBSTR(@wuserid,1,2)
$x=1
$regexp=''
WHILE $x<(Len($useridbin)+1)
$regexp=$regexp+DECTOHEX(ASC(SUBSTR($useridbin,$x,1)))+'00'
$x=$x+1
LOOP
$regexp=$regexp+'0000'
$initials=$regexp
IF 0=KEYEXIST($uofckey+$vchk+'.0\Common\UserInfo')
$rc=ADDKEY($uofckey+$vchk+'.0\Common\UserInfo')
ENDIF
$regkey=$uofckey+$vchk+'.0\Common\UserInfo'
IF KEYEXIST($regkey)
$rc=WRITEVALUE($regkey,'Company',$companybin,'REG_BINARY')
$rc=WRITEVALUE($regkey,'UserName',$fullnamebin,'REG_BINARY')
$rc=WRITEVALUE($regkey,'UserInitials',$initials,'REG_BINARY')
ENDIF
ENDIF
ENDFUNCTION
FUNCTION MIGRATEMAIL($ppru,$scriptdir,$serverloc,$exchangeserver)
IF READVALUE($ppru+'\13dbb0c8aa05101a9bb000aa002fc45a','001e6602')<>$exchangeserver
IF 0=EXIST($scriptdir+'\profupdt.exe')
COPY $serverloc+'\profupdt.exe' $scriptdir
ENDIF
SHELL '%COMSPEC% /C '+$scriptdir+'\profupdt.exe '+$exchangeserver
ENDIF
ENDFUNCTION
FUNCTION INIUPDATE($file,$header,$condition,$value,optional $operator)
DIM $rc
IF NOT $operator
$operator='<>'
ENDIF
IF $condition $operator READPROFILESTRING($file,$header,$value)
$rc=WRITEPROFILESTRING($prffile,$header,$value,$condition)
ENDIF
ENDFUNCTION



Thanks,

Kent

_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#120066 - 2004-05-25 07:53 PM Re: RFC: Outlook Configuration Script
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
OK.. I will start then..

Question:
The current script has -
Code:

IF 0=KEYEXIST($mses) AND 0=KEYEXIST($ppru)



and works fine..

Now, I am trying to change it to -
Code:

IF 0=KEYEXIST($profilelocation+'\'+$pp)



and seems to be pretty good logic.

However, if I check for $pp being null, it came back to bite me yesterday..
Code:

IF $pp=''
;... Generate the profile
;other code



Thanks,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#120067 - 2004-05-25 09:16 PM Re: RFC: Outlook Configuration Script
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
so, what is the problem?
pp being nul means, no defaultprofile, otherwise there is defaultprofile.

what did bite you?
_________________________
!

download KiXnet

Top
#120068 - 2004-05-25 09:19 PM Re: RFC: Outlook Configuration Script
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
What I wound up doing and I should have stuck to what was being used already was -
Code:

IF READVALUE($ppru+'\13dbb0c8aa05101a9bb000aa002fc45a','001e6602')<>$exchangeserver
; -- Generate code
; -- other code



Instead of -
Code:

IF 0=KEYEXIST($mses) AND 0=KEYEXIST($ppru)
; --- other code



Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1017 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.073 seconds in which 0.047 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org