#75126 - 2003-05-21 10:06 PM
Outlook Profile Creation
|
TK
Fresh Scripter
Registered: 2001-08-21
Posts: 10
|
I'm trying to create the Outlook profile for each user as part of the logon script using modprof.exe and two custom *.prf files: outlook1.prf has the setting of PathToPersonalFolders=H:\%username%.pst; meanwhile, outlook2.prf just commented out these personal folder sections. My objective is first to check whether the user has Outlook profile, if NOT then go ahead create the profile either with or without @userid.pst in the user home directory, mapped as H drive (I figured that there are two possibilities: 1/user has no Outlook profile and no existing H:\@userid.pst and 2/user has no Outlook profile and an existing H:\@userid.pst file.). Problem is followed:
** First time logon, scripts works fine. On the second logon, same W2K Pro, Outlook profile gone! Your help is greatly appreciated. Here is the script (I'm using kix32.exe version 4.20.0:
;Check to see if Outlook profile already created, if not, create one for this particular user: $regkey = ReadValue("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles","DefaultProfile") SELECT CASE $regkey <> 0 AND 0=EXIST("H:\@userid.pst") ? shell "%comspec% /c c:\winnt\modprof.exe -P c:\winnt\outlook1.prf" ;Create Outlook profile with @userid.pst file
CASE $regkey <> 0 AND 1=EXIST("H:\@userid.pst")
? shell "%comspec% /c c:\winnt\modprof.exe -P c:\winnt\outlook2.prf" ;Create Outlook profile without @userid.pst file
ENDSELECT
|
|
Top
|
|
|
|
#75128 - 2003-05-23 03:49 AM
Re: Outlook Profile Creation
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
TK,
Are you trying to create a new profile (PROFGEN.EXE)? Or, are you trying to Modify (MODPROF.EXE) a profile?
Creation/checking of an Outlook (or Exchange) profile is covered in the previously mentioned FAQ - Outlook/Exchange Configuration. Even if you don't use the code, there are quite of few resources (links) to helpful information in your quest of creating profiles in Outlook.
BTW, the KiXtart FAQ & How to's strives to be a helpful resource.
Thanks,
Kent [ 23. May 2003, 03:50: Message edited by: kdyer ]
|
|
Top
|
|
|
|
#75129 - 2003-05-23 04:27 AM
Re: Outlook Profile Creation
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
Hey GUys.. I know thins is a big one, but why don't you try to UDF this one...
one or 2 udfs.. One to make a basic profile with exchangeserver and another to add extras like LDAP or PST etc...
Function CreateOutlookProfile($profilename, $servername) ...
|
|
Top
|
|
|
|
#75130 - 2003-05-23 06:14 AM
Re: Outlook Profile Creation
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Rad,
That is a good idea.. However, it tries to be a "one size, fits all" solution. Maybe have one for each version of outlook.. Outlook 97/2000 are roughly the same. Outlook XP is quite a bit different..
Let me see what I can do once I get back from vacation (holiday) in two weeks.
Kent
|
|
Top
|
|
|
|
#75131 - 2003-05-24 12:37 AM
Re: Outlook Profile Creation
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
that is why I think the 2 UDFs would be best.
1 just to make the most basic profile with exchange server and a seperate one to add additional items.
the more advanced scripters could merge the parts together they need for a more efficient, custom solution
|
|
Top
|
|
|
|
#75132 - 2003-05-23 03:32 PM
Re: Outlook Profile Creation
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
I just threw this together from my logonscript.
anyone feel like making it better??
code:
Function OutlookProfile($ProfileName, $ExchangeServer, optional $DefaultStore, optional $MakeDefault) DIM $ProfileKey, $DefaultProfile, $Profile, $File
if @inwin = 2 Exit(1) return endif if not $DefaultStore or val($DefaultStore) < 1 or val($DefaultStore) > 9 $DefaultStore='2' endif if not $MakeDefault $MakeDefault='No' else $MakeDefault='Yes' endif $ProfileKey = "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles" $DefaultProfile = ReadValue($ProfileKey, "DefaultProfile") $Profile = EnumKey($ProfileKey+$ProfileName, 0) IF @error or $profile = '' or $DefaultProfile = '' $DefaultProfile = $ProfileName $File = "%temp%\modprof.PRF" copy "@scriptdir\modprof.PRF" "$File" $ = WRITEPROFILESTRING ($FILE, "General", "Custom", "1") $ = WRITEPROFILESTRING ($FILE, "General", "ProfileName", $DefaultProfile) $ = WRITEPROFILESTRING ($FILE, "General", "DefaultProfile", $MakeDefault) $ = WRITEPROFILESTRING ($FILE, "General", "OverwriteProfile", "Append") $ = WRITEPROFILESTRING ($FILE, "General", "DefaultStore", "Service"+$DefaultStore) $ = WRITEPROFILESTRING ($FILE, "General", "UniqueService", "Yes") $ = WRITEPROFILESTRING ($FILE, "Service List", "Service1", "Microsoft Outlook Client") $ = WRITEPROFILESTRING ($FILE, "Service List", "Service2", "Microsoft Exchange Server") $ = WRITEPROFILESTRING ($FILE, "Service List", "Service3", "Outlook Address Book") $ = WRITEPROFILESTRING ($FILE, "Service List", "Service4", "Microsoft LDAP Directory") $ = WRITEPROFILESTRING ($FILE, "Service2", "HomeServer", $ExchangeServer) $ = WRITEPROFILESTRING ($FILE, "Service2", "MailBoxName", @userid) $ = WRITEPROFILESTRING ($FILE, "Service2", "OfflineAddressBookPath", "%userprofile%\Local Settings\Application Data\Microsoft\Outlook") $ = WRITEPROFILESTRING ($FILE, "Service3", "Ben", "True") SHELL 'cmd /c @scriptdir\modprof.exe -P "$File" -x' sleep 1 DEL "$File" ENDIF
EndFunction
[ 23. May 2003, 15:36: Message edited by: Radimus ]
|
|
Top
|
|
|
|
#75133 - 2003-05-23 06:43 PM
Re: Outlook Profile Creation
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Rad,
Did some cleanup of your code.
code:
Function OutlookProfile($ProfileName, $ExchangeServer, optional $DefaultStore, optional $MakeDefault) DIM $ProfileKey, $DefaultProfile, $Profile, $File if @inwin<>1 Exit(1) return endif if not $DefaultStore or val($DefaultStore)<1 or val($DefaultStore)>9 $DefaultStore=2 endif if $MakeDefault $MakeDefault='Yes' else $MakeDefault='No' endif $UserShell = 'HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders' $LocalAppData = ReadValue($UserShell,'Local AppData') $ProfileKey = 'HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles' $DefaultProfile = ReadValue($ProfileKey,'DefaultProfile') $Profile = EnumKey($ProfileKey+$ProfileName, 0) IF @error or $profile='' or $DefaultProfile='' $DefaultProfile=$ProfileName $File='%temp%\modprof.PRF' copy '@scriptdir\modprof.PRF' '$File' $RC=WRITEPROFILESTRING($FILE,'General','Custom',1) $RC=WRITEPROFILESTRING($FILE,'General','ProfileName',$DefaultProfile) $RC=WRITEPROFILESTRING($FILE,'General','DefaultProfile',$MakeDefault) $RC=WRITEPROFILESTRING($FILE,'General','OverwriteProfile','Append') $RC=WRITEPROFILESTRING($FILE,'General','DefaultStore','Service'+$DefaultStore) $RC=WRITEPROFILESTRING($FILE,'General','UniqueService','Yes') $RC=WRITEPROFILESTRING($FILE,'Service List','Service1','Microsoft Outlook Client') $RC=WRITEPROFILESTRING($FILE,'Service List','Service2','Microsoft Exchange Server') $RC=WRITEPROFILESTRING($FILE,'Service List','Service3','Outlook Address Book') $RC=WRITEPROFILESTRING($FILE,'Service List','Service4','Microsoft LDAP Directory') $RC=WRITEPROFILESTRING($FILE,'Service2','HomeServer',$ExchangeServer) $RC=WRITEPROFILESTRING($FILE,'Service2','MailBoxName',@userid) $RC=WRITEPROFILESTRING($FILE,'Service2','OfflineAddressBookPath',$LocalAppData+'\Microsoft\Outlook') $RC=WRITEPROFILESTRING($FILE,'Service3','Ben','True') SHELL 'cmd /c @scriptdir\modprof.exe -P "$File" -x >nul' sleep 1 DEL "$File" ENDIF EndFunction
Thanks,
Kent
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 591 anonymous users online.
|
|
|