Instead of using %username%, why not replace it with @userid?
 Code:
WriteValue ("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","Personal","D:\"+@userid+"\My Documents","REG_SZ")

Thanks,

Kent Dyer
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's