code:
function OutlookProfile($ProfileName, $ModProfDir, $ExchangeServer, $account, optional $default)
dim $tempfile, $defaultprofile
$WMSProfiles = 'HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles'
$tempfile = '%temp%\modprof.prf'
$DefaultProfile = ReadValue($WMSProfiles, "DefaultProfile")
$default = iif($default and not $DefaultProfile = $ProfileName,'Yes','No')
if not keyexist($WMSProfiles+'\'+$ProfileName)
copy '$ModProfDir\modprof.prf' $tempfile
$ = WRITEPROFILESTRING ($tempfile, 'General', "ProfileName",$ProfileName)
$ = WRITEPROFILESTRING ($tempfile, 'Service2',"HomeServer", $ExchangeServer)
$ = WRITEPROFILESTRING ($tempfile, 'Service2',"MailBoxName",$account)
SHELL 'cmd /c $ModProfDir\modprof.exe -P $tempfile -x'
if not @error $OutlookProfile=1 else exit @error endif
sleep 1
DEL $tempfile
ENDIF
if $default='Yes'
$=writeValue($WMSProfiles,'DefaultProfile',$ProfileName,REG_SZ)
endif
endfunction