I have created (at least tried to...) a script that automatically creates a new outlook profile for a user when he logs on. However I am having some troubles with this script. If I run this script manually on a PC or Server the script works fine, but if I run this script in the users logon script the script does not work. I think the problem is related to the line containing KeyExist. This line checks if a user has a profile for outlook. If I add the following line (messagebox("$ProfileStatus","Test") after that line to see what the value of the variable $ProfilStatus is I get KEYEXIST if I run this script from the logon script, but I get 0 (or 1) when I run the script manually. Other stuff like readvalue and writevalue works great both when I run them manually and through a logon script. Hope someone can help me.

if ingroup("L_App_Outlook") or ingroup("L_App_Office_Pro") or ingroup("L_App_Office_Std") or ingroup("L_App_Office")
$ProfilStatus=KeyExist("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\%username%")
if $ProfilStatus=0
copy "\\eeavir02\Clients\OfficeXPPro\outlook2002.prf" "h:\windows\outlook.prf"
shell "\\eeavir02\Clients\OfficeXPPro\prfpatch.exe"
sleep 2
shell "cmd /c start /max m:\program\micros~1\office10\outlook.exe /importprf h:\windows\outlook.prf"
endif
endif