BREAK ON
CLS
; -- Outlook 2000 Configuration
; -- Kent Dyer
; -- 15 August 2001
; -- This completes the setup of Outlook
; -- Yes, you can use PROFGEN and FIXPRF, but these alone don't complete the setup
; -- They are, however necessary to complete this piece of the script
; -- Two options
; -- * Changes the view to get rid of the Outlook Bar and show the "Explorer View"
; -- * Checks the box to empty deleted items on leaving Outlook
; -- Company key needs to be changed to yours....
; -- Comments and feedback are welcome to - dyerkb@myrealbox.com $hklms = 'HKEY_LOCAL_MACHINE\SOFTWARE'
$hkcus = 'HKEY_CURRENT_USER\SOFTWARE'
$exserver = "EXCHANGESERVER"
$profilelocation = $hkcus+"\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"
$personalprofilelocation = $profilelocation+"\"+@USERID
If 0 <> ExistKey($personalprofilelocation)
; -- Check for Outlook Version 9.x (Office 2000)
$exe=ReadValue($hklms+"\Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE","")
$ver=GetFileVersion("$exe")
$verchk = SubStr ($ver, 1, 1)
If $verchk = "9" ; -- If it is Outlook 2000, configure the following keys and values
; -- CHECK FOR KEYS AND IF NEED BE, ADD THEM
If 0 <> ExistKey($hkcus+"\Software\Microsoft\Office\9.0")
$ = AddKey($hkcus+"\Software\Microsoft\Office\9.0")
EndIf
If 0 <> ExistKey($hkcus+"\Software\Microsoft\Office\9.0\Common")
$ = AddKey($hkcus+"\Software\Microsoft\Office\9.0\Common")
EndIf
If 0 <> ExistKey($hkcus+"\Software\Microsoft\Office\9.0\Common\UserInfo")
$ = AddKey($hkcus+"\Software\Microsoft\Office\9.0\Common\UserInfo")
EndIf
If 0 <> ExistKey($hkcus+"\Software\Microsoft\Office\9.0\Outlook")
$ = AddKey($hkcus+"\Software\Microsoft\Office\9.0\Outlook")
EndIf
If 0 <> ExistKey($hkcus+"\Software\Microsoft\Office\9.0\Outlook\Office Explorer")
$ = AddKey($hkcus+"\Software\Microsoft\Office\9.0\Outlook\Office Explorer")
EndIf
; -- NEW KEYS
; -- Company
$ = WriteValue($hkcus+"\Software\Microsoft\Office\9.0\Common\UserInfo","Company","0000000000000000000000000000000000000000000000000000000000000000000000000","REG_BINARY")
; -- Changes the view to get rid of the Outlook Bar and show the "Explorer View"
$ = WriteValue($hkcus+"\Software\Microsoft\Office\9.0\Outlook\Office Explorer","Frame","010000002c0000000200000003000000ffffffffffffffffffffffffffffffff62000000270000003c030000ac02000001000000000000000100000000000000c00000006400000003000000","REG_BI NARY")
; -- Set the Machine Name
If @WKSTA <> ReadValue($hkcus+"\Software\Microsoft\Office\9.0\Outlook","Machine Name")
$ = WriteValue($hkcus+"\Software\Microsoft\Office\9.0\Outlook","Machine Name",@WKSTA,"REG_SZ")
EndIf
; -- Check Internet E-Mail Accounts
If 1 <> ReadValue($hkcus+"\Software\Microsoft\Office\9.0\Outlook","CheckInternetAccounts")
$ = WriteValue($hkcus+"\Software\Microsoft\Office\9.0\Outlook","CheckInternetAccounts","1","REG_DWORD")
EndIf
; -- Has Outlook been Setup?
If "False" <> ReadValue($hkcus+"\Software\Microsoft\Office\9.0\Outlook","FirstRunDialog")
$ = WriteValue($hkcus+"\Software\Microsoft\Office\9.0\Outlook","FirstRunDialog","False","REG_SZ")
EndIf
EndIf
; -- Now that we have created the appropriate Keys and Registry Values, Let's Generate the user's Profile
IF 1 <> EXIST("%windir%\PROFGEN.exe")
COPY @ldrive+"\Profgen\PROFGEN.EXE" "%windir%"
ENDIF
IF 1 <> EXIST("%windir%\ChkExchg.exe")
COPY @ldrive+"\Profgen\ChkExchg.exe" "%windir%"
ENDIF
IF 1 <> EXIST("%windir%\NEWPROF.EXE")
COPY @ldrive+"\Profgen\NT\NEWPROF.EXE" "%windir%"
ENDIF
IF 1 <> EXIST("%windir%\FixPrf.exe")
COPY @ldrive+"\Profgen\FixPrf.exe" "%windir%"
ENDIF
IF 1 <> EXIST(%userprofile%+"\WINNT.PRF")
COPY @ldrive+"\Profgen\NT\Winnt.prf" "%userprofile%"
ENDIF
; -- Set a Variable to be used for the PRF File
$winntfile = "%UserProfile%\Winnt.prf"
; -- If we open WINNT.PRF in a TEXT Editor,
; -- we notice that it structured the same as an INI file
$profilename = READPROFILESTRING($winntfile,"General","ProfileName")
IF $profilename <> "@userid" OR $profilename = "$USERNAME$"
$ = WRITEPROFILESTRING($winntfile,"General","ProfileName",Chr(37)+"username"+Chr(37))
ENDIF
IF $exserver <> READPROFILESTRING($winntfile,"Service2","HomeServer")
$ = WRITEPROFILESTRING($winntfile,"Service2","HomeServer",$exserver)
ENDIF
$mailboxname = READPROFILESTRING($winntfile,"Service2","MailboxName")
IF $mailboxname <> "@userid" OR $mailboxname = "$USERNAME$"
$ = WRITEPROFILESTRING($winntfile,"Service2","MailboxName",Chr(37)+"username"+Chr(37))
ENDIF
; -- If the userid exists, we don't want to mess with it
IF 0 = EXISTKEY( $personalprofilelocation )
RETURN
ENDIF
; -- If it does not exist, delete out any odd-ball Profiles
; -- Like OEM user, etc.
$index = 0
:loop3
$keyname = ENUMKEY($profilelocation, $index)
IF @error = 0
;? "Name found: $KeyName" ; -- Uncomment for debugging
; -- Going to check for @userid
IF $keyname <> @userid OR $keyname <> "Sales"
$rc = DELTREE($profilelocation+"\"+$keyname)
;$RC = DELKEY($ProfileLocation, $KeyName)
$index = $index + 1
GOTO Loop3
ENDIF
ENDIF
; -- Generate the Inbox
; -- Make sure you use PUTINENV.EXE and WINSET.EXE with 9x machines - We need to have the %USERNAME% available
; -- "Secondary Inbox" is an alternate to keep
$returncode= EXISTKEY($personalprofilelocation) OR EXISTKEY($profilelocation+"\Secondary Inbox")
;?$ReturnCode ; -- Uncomment for debugging
IF $returncode <> 0
;Edit the copied mail profile to make it the userid.
;run "%WINDIR%\fixpatch.exe @USERID"
;The quotes here are important with Windows 2000 Machines as the user profile is
;under \DOCUMENTS AND SETTTINGS\USERID and KIX appears to not like spaces in file/folder names
RUN '%WINDIR%\Fixprf.exe "%UserProfile%\Winnt.prf" @userid @userid $ExServer'
; -- Had to add a small pause
SLEEP 1
RUN '%WINDIR%\Newprof.exe -p "%UserProfile%\Winnt.prf" -x'
;If you want to use PROFGEN, uncomment the next line and comment the one for FIXPRF.EXE
;RUN '%WINDIR%\PROFGEN.EXE %WINDIR%\NEWPROF.EXE -P "%UserProfile%\WINNT.PRF" @userid -r -l'
;Write new default mail profile based on USERID
;Had to add a small pause for this next step
SLEEP 1
$ = writevalue($profilelocation, "DefaultProfile", @userid, "REG_SZ")
ENDIF
; -- Check for the Default profile, if it does not exist, create it
IF @userid <> READVALUE( $profilelocation, "DefaultProfile" )
$ = WRITEVALUE ($profilelocation, "DefaultProfile", @userid, "REG_SZ")
ENDIF
; -- Check the box to empty deleted items on leaving Outlook - Now the we have the Outlook Profile Generated
IF "0100" <> READVALUE($hkcus+"\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\@USERID\0a0d020000000000c000000000000046","000b0115")
$ = WRITEVALUE($hkcus+"\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\@USERID\0a0d020000000000c000000000000046","000b0115","0100","REG_BINARY")
ENDIF
RETURN
ELSE
RETURN
ENDIF