Jump to content

Recommended Posts

Posted

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

Posted

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.

  • Thanks 1
Posted

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

Posted

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?

  • Thanks 1

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...