Click here to return to the KiXtart HelpDesk main page...

KiXtart Script Depot

Exchange Roaming User på Win 9x/NT og med Outlook profiles

; ScriptName:  RoamingExchange2.kix
; Author:      Hans.Bruman@accept.se
; Date:          28.06.1999     
; Description: Example of automatic creation of Outlook profile on both Windows 9x and NT.
;                   Scriptet shall/can be startd in HKLM\...\RunOnce

; Fix route...
color w/n cls
color y+/b box(5,15,20,65,single)
at(5,16)" Outlook konfig "

; Set $os for right path to profile...
if @InWIN = 1
   $os="\Windows NT\CurrentVersion"
else
   $os=""
endif

at(7,16) " Setting variables & constants"

; Constants for creating Outlook profile...
; $ExchangeServer = "CPNTS2"
; $s_profstr = "\\CPNTS1\netlogon\kix\outlook\default.prf"
; $c_profstr = "Q:\outlook\default.prf"
; $newprofpath = "\\CPNTS1\netlogon\kix\outlook\newprof -P"
; $winsetpath = "\\CPNTS1\netlogon\winset"
; $outlook_group = "G outlook"
; $username = @userid

$ExchangeServer = "CPNTS2"
$s_profstr = "\\CPNTS1\netlogon\kix\outlook\default.prf"
$c_profstr = "\\cpnts1\" + @userid + "$\outlook\default.prf"
$newprofpath = "\\CPNTS1\netlogon\kix\outlook\newprof -P"
$winsetpath = "\\CPNTS1\netlogon\winset"
$outlook_group = "Domain users"
$ost_group = "portabel dator"
$username = @userid

; Outlook registry search...
;
$olk_ost = "HKEY_CURRENT_USER\Software\Microsoft\Office\8.0\Outlook\OST"
$olk_prfbase = "HKEY_CURRENT_USER\Software\Microsoft" + $os + "\Windows Messaging Subsystem\Profiles\" + $username

; Is the user in the NT group $outlook_group...
if INGROUP( $outlook_group ) 
    at(8,16) " Kontrollerer Outlook..."
; Does this user allready have an Outlook profile ?
; $Return = existkey($olk_prfbase)
    if existkey($olk_prfbase) = 0
; Skip all Outlook code...
        at(10,16) " Outlook redan konfigurerad.."
        goto klar
    endif
    at(10,16) " Konfigurerer Outlook..."
; Fix Outlook profile, with newprof.exe...
    at(12,16) " Opretter " + c_profstr
    DEL $c_profstr
    copy $s_profstr $c_profstr
    $returncode = writeprofilestring($c_profstr,"general","profilename",$username)
    $returncode = writeprofilestring($c_profstr,"service2","MailboxName",$username)
    $returncode = writeprofilestring($c_profstr,"service2","HomeServer",$ExchangeServer)
    $returncode = writeprofilestring($c_profstr,"service2","OfflineFolderPath","")
    $execstr = $newprofpath + " " + $c_profstr +" -X"
    SHELL $execstr

; Remove OST file options...
; Maybe this should depend upon a NT Global Group ?

    at(16,16) " Kontrollerer OST muligheder.."
    if INGROUP( $ost_group )
; Remove the NoOST parameter...
        $returncode = delkey($olk_ost)
    else
        if existkey($olk_ost)
            $returncode = addkey($olk_ost)
            $returncode = writevalue($olk_ost,"NoOST","2","REG_DWORD")
        else
            if addkey($olk_ost) <> 0 
                at(18,16) " Couldnt create registry entry !"
            else
                $returncode = writevalue($olk_ost,"NoOST","2","REG_DWORD")
            endif
        endif 
    endif
endif

; Klar...
:klar
at(18,16) " Konfiguration klar..."
at(24,1)

Exit 1