Changing the User Initials of Office 2003 Applications using VB Script

I had posted a question previously in order to change the Username Popup Box when Office 2003 Applications are opened.

http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/Remote_Desktop-Terminal_Services/Q_25335235.html

Now I have a similar requirement, but this time I need a VB Script that can change the User Initials in addition to Username field of the popup box which opens up when a new user opens Word, Excel or Powerpoint.
LVL 19
vmwarun - ArunAsked:
Who is Participating?
 
yehudahaCommented:
i think this will do

at the end of your script add this code:
call ini

sub ini
      Set objnet = CreateObject("WScript.Network")
Set objWord = CreateObject("Word.Application")
strInput = msgbox("Update Your Initial For Office Application ?",4)
Select Case strInput
Case 6
objWord.UserInitials = objnet.username
objWord.Quit
Case 7
objWord.Quit
End Select
end sub

Open in new window

0
 
yehudahaCommented:
change it to what ?
0
 
vmwarun - ArunAuthor Commented:
This was the previous VB Script which was given by one of the Experts.
 
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
vmwarun - ArunAuthor Commented:

Set oFSO = CreateObject("Scripting.FileSystemObject") 
Set oShell = CreateObject("Wscript.Shell") 
 
' get UserName 
strUsername = oShell.ExpandEnvironmentStrings("%USERNAME%") 
 
'msgbox strusername 
 
' Convert UserName to hex 
For i = 1 to Len(strUsername) 
  strUsernameHex = strUsernameHex & "," & Hex(Asc(Mid(strUsername, i, 1))) & ",00" 
Next 
strUsernameHex = Right(strUsernameHex, Len(strUsernameHex) -1) 
strUsernameHex = strUsernameHex & ",00,00" 
 
' Create temporary registry file 
Const OverwriteIfExist = -1 
Const FailIfExist      = 0 
Const OpenAsASCII   =  0 
Const OpenAsUnicode = -1 
Const OpenAsDefault    = -2 
sTmpFile = oShell.ExpandEnvironmentStrings("%TEMP%") & "\UserInfo.reg" 
Set fFile = oFSO.CreateTextFile(sTmpFile, OverwriteIfExist, OpenAsASCII) 
 
' Write to the temporary registry file 
fFile.WriteLine "REGEDIT4" 
fFile.WriteLine 
fFile.WriteLine "[HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\UserInfo]" 
fFile.WriteLine """UserName""=hex:" & strUsernameHex 
fFile.Close 
 
' Import the registry file 
oShell.Run "regedit /s " & sTmpFile, 0, True 
 
' Delete the temporary registry file 
oFSO.DeleteFile sTmpFile

Open in new window

0
 
yehudahaCommented:
you want to change the initial to the user log on ?
0
 
yehudahaCommented:
user name or display name ?

johnd or jhon doe
0
 
vmwarun - ArunAuthor Commented:
Yes, intial to the user logon on. For initials I would prefer to leave them empty, so if user requires, they can update it for the first time.
0
 
yehudahaCommented:
save as vbs

you will ask the user if he want to update his initial, will update user name
if you want some thing else to update let me know
Set objnet = CreateObject("WScript.Network")
Set objWord = CreateObject("Word.Application")
strInput = msgbox("Update Your Initial For Office Application ?",4)
Select Case strInput
Case 6
objWord.UserInitials = objnet.username
objWord.Quit
Case 7
objWord.Quit
End Select

Open in new window

0
 
vmwarun - ArunAuthor Commented:
Let me check and update.
0
 
yehudahaCommented:
Works ?
0
 
vmwarun - ArunAuthor Commented:
I was unable to check because I was held up with other issues. I will check and update tomorrow.
0
 
vmwarun - ArunAuthor Commented:
We already added the code to Production attached by me, so is it possible to add or modify the code and update it accordingly,
0
 
vmwarun - ArunAuthor Commented:
Let me check this by adding these additional lines of code and reply back.
0
 
vmwarun - ArunAuthor Commented:
I was not able to put this in Production but I would like to award points for the assistance.
0
 
yehudahaCommented:
many thanks
0
 
ariadminCommented:
Anyway to edit the script to only use the first 9 characters of a 'username' since the initials variable is limited to 9 characters? While i love this script, users with long last names are getting errors (string too long).

thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.