Office 2010: REG_EXPAND_SZ and Variable Substring Selection?
I have found that Smart Ink Tools Addin for Office 2010 fails to load properly if the user is prompted to enter a Username and Userinitials when an Office product is first started. In the effort to prevent this prompt from happening, I have found that some registry values need to be present. Namely:
Configuring these values as a REG_EXPAND_SZ allows me to user the %username% variable as such:
reg add HKCU\Software\Microsoft\Office\Common\Userinfo /v Username /t REG_EXPAND_SZ /d "%%username%%" /f
Which ends up working great. When I start Office, the REG_EXPAND_SZ is expanded, and is replaced with a REG_SZ equal to the username.
However, I am having an issue with the UserInitials part. My attempt is:
reg add HKCU\Software\Microsoft\Office\Common\Userinfo /v Username /t REG_EXPAND_SZ /d "%%username:~0,2%%" /f
Which should get the first two characters of the Username variable. This works when testing in a cmd prompt, but when the REG_EXPAND_SZ ends up expanding, it only drops the first character in the resulting REG_SZ. I tried %username:~0,3% with the same results.
Does anybody know what is going on here?
Tested with %username% as the value for both UserName and UserInitials, and found that it preserved the keys (not replacing them as I had thought). It seems that the issue is with regards to the substring selection idea, %username:~0,2%. If I have that configured as one of the values, it fails entirely and replaces my keys with the default keys, which is the username, and then the initials.
REG_EXPAND_SZ does not support substring functionality. Ended up copying batch file to system and creating a RunOnce value for the default user so that each user executes the script at first login.
The below works for me with no issues. I changed the values back to REG_SZ and used the UserName variable just like you wanted.
reg add HKCU\Software\Microsoft\Office\Common\Userinfo /v UserName /t REG_SZ /d %username% /f
reg add HKCU\Software\Microsoft\Office\Common\Userinfo /v UserInitials /t REG_SZ /d %username:~0,2% /f