cwhitmore
(Starting to like KiXtart)
2004-01-22 05:07 PM
Outlook/Exchange script help?

I used the Outlook script provided in the HOWTO forum, but I'm having trouble getting it to work. It creates a profile for the user, but the profile is blank. Here is code I have at the top of Outlook.kix: (I'm using Office XP Pro)

;Some initial settings
$profile_remove='Yes' ; Remove All other Outlook profiles under current user
$deleteitems='No'; 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='FromSrv.prf'
$company='Advocacy, Inc.'
$serverloc='\\server1\Netlogon\Functions' ; Outlook Executables/files location
$exchangeserver='EXCHANGE' ; Main Exchange Server Location

I have Outlook.kix in \Functions along with Profgen.exe, NewProf.exe and FromSrv.prf

I'm calling the script from my testlogin.bat batch file:

Call '\\server1\NETLOGON\functions\Outlook.kix'
MessageBox ("Finished process", "Scripts",1,3)
Exit

What am I missing?
Carlton.


Sealeopard
(KiX Master)
2004-01-22 05:09 PM
Re: Outlook/Exchange script help?

Please read ABC's of KiXtart board etiquette and message to new forum users and refrain from double/cross-posting.

cwhitmore
(Starting to like KiXtart)
2004-01-22 05:43 PM
Re: Outlook/Exchange script help?

Oops, wasn't sure which forum this post should go in so I posted in both. Can someone help me with this script?
Carlton.


LonkeroAdministrator
(KiX Master Guru)
2004-01-22 06:49 PM
Re: Outlook/Exchange script help?

this is not so much related to the script you run but more to the way our faq suggests running profile generation...
there is in ORK toolbox new tool called modprof.exe
kent or someone who can answer, why we ain't using that?


Kdyer
(KiX Supporter)
2004-01-23 06:02 AM
Re: Outlook/Exchange script help?

Here..

Here is a bit of a "silver platter"..



You should not need PROFGEN.EXE, MODPROF.EXE, NEWPROF.EXE etc. But, you still need the PRF file.

Code:

;Some initial settings
$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='FromSrv.prf'
$company='Advocacy, Inc.'
$serverloc=@lserver+'\Netlogon\Profgen\Outlook2000' ; Outlook files location
$exchangeserver='EXCHANGE' ; Main Exchange Server Location
;Registry locations
$ushelfolders='HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders'
$userwinkey='HKCU\Software\Microsoft\Windows'
$machinewinkey='HKLM\Software\Microsoft\Windows'
$mofckey='HKLM\Software\Microsoft\Office\'
$uofckey='HKCU\Software\Microsoft\Office\'

IF @inwin=1
;Windows NT/2k/XP/2003
$profilelocation=$userwinkey+' NT\CurrentVersion\Windows Messaging Subsystem\Profiles'
$scriptdir=SUBSTR(READVALUE($ushelfolders,'Desktop'),1,LEN(READVALUE($ushelfolders,'Desktop'))-8)
ELSE
;Windows 9x
$profilelocation=$userwinkey+' Messaging Subsystem\Profiles'
;Need to insure that each user has their own desktop via the password applet in the Co ntrol Panel
$scriptdir=READVALUE('HKLM\Software\Microsoft\Windows\CurrentVersion\ProfileList\'+@USERID,'ProfileImagePath')
ENDIF

$prffile=$scriptdir+'\'+$prf
$ppru=$profilelocation+'\'+@userid
$mses=$profilelocation+'\MS Exchange Settings'
$exe=ReadValue($machinewinkey+'\CurrentVersion\App Paths\OUTLOOK.EXE','')
$ver=GetFileVersion($exe)
$verchk=SPLIT($ver,'.')[0]

MSUSERINFO
IF KeyExist($ppru) OR KeyExist($mses)
RETURN
ELSE
IF 0=Exist($scriptdir)
MD $scriptdir
ENDIF
COPY $serverloc+'\'+$prf $profiledir+'\'+$prf

PRFSETTINGS

IF $profile_remove='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

OUTLOOK10AND11('10.0')

FUNCTION PRFSETTINGS()
; Custom Profile Settings
IF @userid<>ReadProfileString($prffile,'General','ProfileName')
$rc=WriteProfileString($prffile,'General','ProfileName',@userid)
ENDIF
IF 'Yes'<>ReadProfileString($prffile,'General','DefaultProfile')
$rc=WriteProfileString($prffile,'General','DefaultProfile','Yes')
ENDIF
IF $exchangeserver<>ReadProfileString($prffile,'Service2','HomeServer')
$rc=WriteProfileString($prffile,'Service2','HomeServer',$exchangeserver)
ENDIF
IF @userid<>ReadProfileString($prffile,'Service2','MailboxName')
$rc=WriteProfileString($prffile,'Service2','MailboxName',@userid)
ENDIF
IF 'TRUE'<>ReadProfileString($prffile,'Service1','AutoNameCheck')
$rc=WriteProfileString($prffile,'Service1','AutoNameCheck','TRUE')
ENDIF
IF 'FALSE'<>ReadProfileString($prffile,'Service1','ConfirmOnDelete')
$rc=WriteProfileString($prffile,'Service1','ConfirmOnDelete','FALSE')
ENDIF
IF $deleteitems='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
IF 'FALSE'<>ReadProfileString($prffile,'Service1','RemoveSchdPlus')
$rc=WriteProfileString($prffile,'Service1','RemoveSchdPlus','FALSE')
ENDIF
IF 'TRUE'<>ReadProfileString($prffile,'Service1','SelectEntireWord')
$rc=WriteProfileString($prffile,'Service1','SelectEntireWord','TRUE')
ENDIF
IF 'TRUE'<>ReadProfileString($prffile,'Service1','CloseOriginalMessage')
$rc=WriteProfileString($prffile,'Service1','CloseOriginalMessage','TRUE')
ENDIF
IF 'FALSE'<>ReadProfileString($prffile,'Service1','GenReadReceipt')
$rc=WriteProfileString($prffile,'Service1','GenReadReceipt','FALSE')
ENDIF
IF 'FALSE'<>ReadProfileString($prffile,'Service1','GenDeliveryReceipt')
$rc=WriteProfileString($prffile,'Service1','GenDeliveryReceipt','FALSE')
ENDIF
IF 'True'<>ReadProfileString($prffile,'Service1','SaveSentMail')
$rc=WriteProfileString($prffile,'Service1','SaveSentMail','True')
ENDIF
IF 'No'<>ReadProfileString($prffile,'General','BackupProfile')
$rc=WriteProfileString($prffile,'General','BackupProfile','No')
ENDIF
ENDFUNCTION

FUNCTION OUTLOOK10AND11($vers)
$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 $explorview='Yes' AND $vers='10.0' ;Don't change version 11
$expview='010000002c0000000200000003000000ffffffffffffffffffffffffffffffff2c0000002c00000084'
$expview=$expview+'020000dc01000001000000000000000100000000000000c0000000640000001800000003000000'
$rc=WriteValue($uofckey+$vers+'\Outlook\Office Explorer','Frame',$expview,'REG_BINARY')
ENDIF
ENDFUNCTION

FUNCTION MSUSERINFO()
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+$ver+'\Common\UserInfo')
$rc=AddKey($uofckey+$ver+'\Common\UserInfo')
ENDIF
$regkey=$uofckey+$ver+'\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


HTH,

Kent


NTDOCAdministrator
(KiX Master)
2004-01-23 08:43 AM
Re: Outlook/Exchange script help?

Kent,

You say you don't need PROFGEN yet you have this line in the code.

$serverloc=@lserver+'\Netlogon\Profgen\Outlook2000' ; Outlook Executables/files location



Kdyer
(KiX Supporter)
2004-01-23 02:13 PM
Re: Outlook/Exchange script help?

Doc,

Thanks for the clarification..

I changed it to -

$serverloc=@lserver+'\Netlogon\Profgen\Outlook2000' ; Outlook files location

You still need the PRF file under Outlook XP/2003.

Kent


Kdyer
(KiX Supporter)
2004-01-23 02:36 PM
Re: Outlook/Exchange script help?

Here is the final code to address Outlook XP/2003.

;Some initial settings 
$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='FromSrv.prf'
$company='Advocacy, Inc.'
$serverloc=@lserver+'\Netlogon\Profgen\Outlook2000' ; Outlook files location
$exchangeserver='EXCHANGE' ; Main Exchange Server Location
;Registry locations
$ushelfolders='HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders'
$userwinkey='HKCU\Software\Microsoft\Windows'
$machinewinkey='HKLM\Software\Microsoft\Windows'
$mofckey='HKLM\Software\Microsoft\Office\'
$uofckey='HKCU\Software\Microsoft\Office\'

IF @inwin=1
;Windows NT/2k/XP/2003
$profilelocation=$userwinkey+' NT\CurrentVersion\Windows Messaging Subsystem\Profiles'
$scriptdir=SUBSTR(READVALUE($ushelfolders,'Desktop'),1,LEN(READVALUE($ushelfolders,'Desktop'))-8)
ELSE
;Windows 9x
$profilelocation=$userwinkey+' Messaging Subsystem\Profiles'
;Need to insure that each user has their own desktop via the password applet in the Co ntrol Panel
$scriptdir=READVALUE('HKLM\Software\Microsoft\Windows\CurrentVersion\ProfileList\'+@USERID,'ProfileImagePath')
ENDIF

$prffile=$scriptdir+'\'+$prf
$ppru=$profilelocation+'\'+@userid
$mses=$profilelocation+'\MS Exchange Settings'
$exe=ReadValue($machinewinkey+'\CurrentVersion\App Paths\OUTLOOK.EXE','')
$ver=GetFileVersion($exe)
$verchk=SPLIT($ver,'.')[0]

MSUSERINFO
IF KeyExist($ppru) OR KeyExist($mses)
RETURN
ELSE
IF 0=Exist($scriptdir)
MD $scriptdir
ENDIF
COPY $serverloc+'\'+$prf $profiledir+'\'+$prf

PRFSETTINGS

IF $profile_remove='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

OUTLOOK10AND11('10.0')

FUNCTION PRFSETTINGS()
; Custom Profile Settings
IF @userid<>ReadProfileString($prffile,'General','ProfileName')
$rc=WriteProfileString($prffile,'General','ProfileName',@userid)
ENDIF
IF 'Yes'<>ReadProfileString($prffile,'General','DefaultProfile')
$rc=WriteProfileString($prffile,'General','DefaultProfile','Yes')
ENDIF
IF $exchangeserver<>ReadProfileString($prffile,'Service2','HomeServer')
$rc=WriteProfileString($prffile,'Service2','HomeServer',$exchangeserver)
ENDIF
IF @userid<>ReadProfileString($prffile,'Service2','MailboxName')
$rc=WriteProfileString($prffile,'Service2','MailboxName',@userid)
ENDIF
IF 'TRUE'<>ReadProfileString($prffile,'Service1','AutoNameCheck')
$rc=WriteProfileString($prffile,'Service1','AutoNameCheck','TRUE')
ENDIF
IF 'FALSE'<>ReadProfileString($prffile,'Service1','ConfirmOnDelete')
$rc=WriteProfileString($prffile,'Service1','ConfirmOnDelete','FALSE')
ENDIF
IF $deleteitems='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
IF 'FALSE'<>ReadProfileString($prffile,'Service1','RemoveSchdPlus')
$rc=WriteProfileString($prffile,'Service1','RemoveSchdPlus','FALSE')
ENDIF
IF 'TRUE'<>ReadProfileString($prffile,'Service1','SelectEntireWord')
$rc=WriteProfileString($prffile,'Service1','SelectEntireWord','TRUE')
ENDIF
IF 'TRUE'<>ReadProfileString($prffile,'Service1','CloseOriginalMessage')
$rc=WriteProfileString($prffile,'Service1','CloseOriginalMessage','TRUE')
ENDIF
IF 'FALSE'<>ReadProfileString($prffile,'Service1','GenReadReceipt')
$rc=WriteProfileString($prffile,'Service1','GenReadReceipt','FALSE')
ENDIF
IF 'FALSE'<>ReadProfileString($prffile,'Service1','GenDeliveryReceipt')
$rc=WriteProfileString($prffile,'Service1','GenDeliveryReceipt','FALSE')
ENDIF
IF 'True'<>ReadProfileString($prffile,'Service1','SaveSentMail')
$rc=WriteProfileString($prffile,'Service1','SaveSentMail','True')
ENDIF
IF 'No'<>ReadProfileString($prffile,'General','BackupProfile')
$rc=WriteProfileString($prffile,'General','BackupProfile','No')
ENDIF
ENDFUNCTION

FUNCTION OUTLOOK10AND11($vers)
$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 $explorview='Yes' AND $vers='10.0' ;Don't change version 11
$expview='010000002c0000000200000003000000ffffffffffffffffffffffffffffffff2c0000002c00000084'
$expview=$expview+'020000dc01000001000000000000000100000000000000c0000000640000001800000003000000'
$rc=WriteValue($uofckey+$vers+'\Outlook\Office Explorer','Frame',$expview,'REG_BINARY')
ENDIF
ENDFUNCTION

FUNCTION MSUSERINFO()
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+$ver+'\Common\UserInfo')
$rc=AddKey($uofckey+$ver+'\Common\UserInfo')
ENDIF
$regkey=$uofckey+$ver+'\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


HTH,

Kent


cwhitmore
(Starting to like KiXtart)
2004-01-23 04:42 PM
Re: Outlook/Exchange script help?

Thanks for the updated script. I'm out of the office today, but I'll try it on Monday.
Cheers,
Carlton.


Kdyer
(KiX Supporter)
2004-01-23 04:58 PM
Re: Outlook/Exchange script help?

Please do notice it only includes just Outlook XP/2003. If you need an 'all inclusive' or all versions of Outlook, please refer back to the FAQ script.

Kent


cwhitmore
(Starting to like KiXtart)
2004-01-26 09:05 PM
Re: Outlook/Exchange script help?

Kent,
Can't I paste your script in where the existing Outlook10or11 code was on the "all inclusive" script?
That way I can use your code with the existing script?
Carlton.


Kdyer
(KiX Supporter)
2004-01-26 09:38 PM
Re: Outlook/Exchange script help?

yes, you should be able to do that.. However, you will need to replace your Company Name, and the EXCHANGE server. If it looks like you cannot see the script, you may need to copy the code into Word, reselect it all and then paste it into your .KIX script.

Kent