Chris_Jones Posted September 26, 2013 Posted September 26, 2013 Hello all, I'm looking for a way, probably via a script. to set the office user name to match the users network name at logon. all our pupils are on mandatory profiles so the username field is just a generic SchoolUser for all of them. any suggestions on this would be much appreciated. Cheers
Michael Posted September 26, 2013 Posted September 26, 2013 Microsoft Office 2010 stores this info in the registry: HKCU\SOFTWARE\Microsoft\Office\Common\UserInfo The entries are: UserInitials and UserName. In theory you could write a script to populate these entries with the user logging on. 1
Chris_Jones Posted September 26, 2013 Author Posted September 26, 2013 In theory, but I don't know much scripting! any suggestions?
Michael Posted September 26, 2013 Posted September 26, 2013 There are some scripting gurus on this forum, I'm sure someone can knock up some code together. Any takers?
mavhc Posted September 26, 2013 Posted September 26, 2013 On error Resume next Set objWord = CreateObject("Word.Application") objWord.UserName = objUser.givenName & " " & objUser.SN objWord.UserInitials = Left(objUser.givenName, 1) & Left(objUser.SN, 1) objWord.Quit
Chris_Jones Posted September 27, 2013 Author Posted September 27, 2013 mavhc, I presume that is vb script? could you give a bit of explanation on what it does, as when I run it, it doesn't seem to change the username in office. Cheers
mavhc Posted October 1, 2013 Posted October 1, 2013 It's a vbscript, yes. First problem is I missed off 2 lines that should have happened previously Add these 2 lines to the start: Set ADSysInfo = CreateObject("ADSystemInfo") -- creates an object to get info about the current user Set objUser = GetObject("LDAP://" & ADSysInfo.UserName) -- gets their user object from their username On error Resume next -- ignores errors, probably best to remove that line whilst debugging Set objWord = CreateObject("Word.Application") -- load MS Word for scripting objWord.UserName = objUser.givenName & " " & objUser.SN -- objUser is a previously defined object, I'll get back to that objWord.UserInitials = Left(objUser.givenName, 1) & Left(objUser.SN, 1) -- this takes the first letter of givenname and surname and makes initials from them objWord.Quit -- close MS word for scripting. Hey, Scripting Guy!: Who Are You? 1
Chris_Jones Posted October 2, 2013 Author Posted October 2, 2013 Just tested that and it seems to work fine for our users. Cheers!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now