WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Samples from Users
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Outlook Exchange Mail Profile Maker

Keywords: 	 outlook exchange mail profiles

;///////////////////////////////////////////
;//
;//  Winbatch Outlook Mail Profile Maker
;//
;///////////////////////////////////////////

If IsKeyDown(@CTRL & @SHIFT) Then Debug(1)

wm=WinMetrics(-4)
If wm == 4		;nt
	AddExtender("WWWNT34I.DLL")
	plat="wNT"
	userid=Environment("USERNAME")
	cname=Environment("COMPUTERNAME")
	homepath=wntGetCon("F:")
	regstr="Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"
else				;95/98
;	AddExtender("WWW9x34I.DLL")
	AddExtender("WWW9534I.DLL")
	plat="w95"
	domain=RegQueryValue(@REGMACHINE,"SYSTEM\CurrentControlSet\Services\MSNP32\NetWorkProvider[AuthenticatingAgent]")
	userid=w95GetUser(domain)
	homepath=w95GetCon("F:")
	cname=RegQueryValue(@REGMACHINE,"System\CurrentControlSet\Control\ComputerName\ComputerName[ComputerName]")
	regstr="Software\Microsoft\Windows Messaging Subsystem\Profiles"
Endif

cur_dir=DirGet()		;DirHome()
windir=DirWindows(0)
ini=StrCat(cur_dir,"mkprofile.ini")
log=IniReadPvt("Settings","MKLogfile","",ini)

If IsKeyDown(@Ctrl & @Shift) Then Debug(1)

;1. Check to see if Windows Messaging has been installed, if not, log event and exit.
ErrorMode(@off)
rslt=RegExistKey(@REGCURRENT,regstr)
ErrorMode(@Notify)
If rslt == 0
	Beep
	IniWritePvt(cname,TimeYmdHms(),"Cannot create profile, Windows Messaging Not Installed!",log)
	Exit
Endif 

;2. Check to see if Outlook 97 has been installed, if not, log event and exit.
ErrorMode(@off)
rslt=RegExistValue(@REGMACHINE,"SOFTWARE\Microsoft\Office\8.0\Outlook[Registered]")
ErrorMode(@Notify)
If rslt == 0
	Beep
	IniWritePvt(cname,TimeYmdHms(),"Cannot create profile, Microsoft Outlook 97 hasn't been installed yet!",log)
	Exit
Endif 

;3. Check to see if current user has a valid email profile, if valid, log and exit,  if not valid continue.
; This may not be completely accurate as most profiles to date are called "Exchange Server" or something like
; that, may need additional or different qualifications of a valid profile.

ErrorMode(@off)
rslt=RegExistKey(@REGCURRENT,"Software\Microsoft\Windows Messaging Subsystem\Profiles\%userid%")
ErrorMode(@Cancel)
If rslt == 1
	Beep
	IniWritePvt(cname,"Profile Status","User %userid% has profile installed!",log)
	Exit
Endif 

;3a. From Step 3 above, may need additional qualifications of what a valid profile is here...

;Check to see if mkprofile has already been run. This value will be 0 
;fullname=RegQueryValue(@REGCURRENT,StrCat(regstr,"\",key,"\13dbb0c8aa05101a9bb000aa002fc45a[001e3001]")) 


;4. Check to see if Winbatch script has been run for this user. (The full email profile is not created until after Outlook has been started for the first time after running NEWPROF.) If script has been run, log and exit, else continue.


; Path of personal folders, 
locpath=IniReadPvt("Settings","PersonalFolderPath","",ini)

If !DirExist(locpath) Then DirMake(locpath)

profile=StrCat(DirWindows(0),"outlook.prf")

; Copy profile file down to windows directory.
FileCopy(StrCat(cur_dir,"template.prf"),profile,@false)

; write userid to profile
IniWritePvt("General","ProfileName",userid,profile)
; write default archive path to profile.
IniWritePvt("Service1","DefaultArchiveFile",StrCat(locpath,"\",userid,"_archive.pst"),profile)
IniWritePvt("Service2","MailboxName",userid,profile)
exchsrv=IniReadPvt("Settings","ExchangeServer","",ini)
IniWritePvt("Service2","HomeServer",exchsrv,profile)
IniWritePvt("Service4","PathToPersonalAddressBook",StrCat(locpath,"\",userid,".pab"),profile)
IniWritePvt("Service5","PathToPersonalFolders",StrCat(locpath,"\",userid,".pst"),profile)


; Run NEWPROF

RunShell(StrCat(cur_dir,"newprof.exe"),"-P %windir%outlook.prf -S -X",cur_dir, @normal, @nowait)

Exit


Article ID:   W14297
Filename:   Outlook Exchange Mail Profile Maker.txt
File Created: 2001:03:01:12:22:44
Last Updated: 2001:03:01:12:22:44