+ Post New Thread
Results 1 to 4 of 4
How do you do....it? Thread, Updating the Officer Username in Technical; This one has bugged me for a long time but ive finally stolen someone elses code Sorry I cannot give ...
  1. #1

    Join Date
    Sep 2005
    Posts
    143
    Thank Post
    0
    Thanked 3 Times in 3 Posts
    Rep Power
    18

    Updating the Officer Username

    This one has bugged me for a long time but ive finally stolen someone elses code Sorry I cannot give credit as I have no idea who made it.
    This is useful under the following scenario:

    Staff use spreadsheets as 'databases'
    Staff1 opens excel.xls
    Staff2 opens excel.xls and cannot edit because Staff1 has locked it.
    Staff2 gets the message cannot open excel.xls for writing because 'Administrator' has the file open ('Administrator' is used because the default profile is set when the workstation image is made)
    Staff2 whinges to techs because they want to edit.

    By using this code as a login script it will update staff members username in tools->options->general->User Name (and initials) to their current username. This will give them the error: cannot open excel.xls because 'Staff1' has the file open. Staff2 promptly whinges to Staff1. YAY! Less whinging.

    The only thing you will have to change is the strOfficePath to your relevant version, Office 2003 is 11.0 which is what I have used.

    UpdateOfficeUserName.vbs
    Code:
    Set nw = CreateObject("WScript.Network")
    
    Const HKEY_CURRENT_USER = &H80000001
    
    strOfficePath = "Software\Microsoft\Office\11.0\Common\UserInfo"
    strMachineName = "."
    strUserName = nw.UserName
    
    max = len(strUserName)
    For intLoop = 1 to max step 1
        asciiName = asc(mid(strUserName, intLoop, 1))
        if newAsciiName = ""  and newAsciiInitials = "" Then
            newAsciiName = asciiName
            'newAsciiInitials = asciiName
        else
            newAsciiName = newAsciiName & "," & "00" & "," & asciiName
        end if
        If intLoop <= 2 then
            newAsciiInitials = newAsciiName & "," & "00"
        End If
    Next
    updateName = Split(newAsciiName,",")
    updateInitials = Split(newAsciiInitials,",")
    strMoniker = "winMgmts:\\" & strMachineName & "\root\default:StdRegProv"
    Set oReg = GetObject(strMoniker)
    userNameSet = oReg.SetBinaryValue(HKEY_CURRENT_USER, strOfficePath, "UserName", updateName)
    userInitialsSet = oReg.SetBinaryValue(HKEY_CURRENT_USER, strOfficePath, "UserInitials", updateInitials)

  2. #2
    Ryan's Avatar
    Join Date
    Jan 2008
    Location
    Scotland
    Posts
    537
    Thank Post
    12
    Thanked 16 Times in 15 Posts
    Blog Entries
    1
    Rep Power
    29
    Out of interest, what's your setup? Where's it pulling "Administrator" from?

    Lots of our staff use Excel spreadsheets in the same manner, but the dialog box always tells them the user account of the person who has it open.

  3. #3

    Join Date
    Sep 2005
    Posts
    143
    Thank Post
    0
    Thanked 3 Times in 3 Posts
    Rep Power
    18
    Well,
    The Default User profile is made before the workstation is imaged. When you run office for the first time it sets the Username in office as your workstation username.
    Last time I did this I removed the user info before I imaged the workstation so that when people logged in it wouldnt have administrator and ask them to confirm their username.
    That worked out fine until they noticed a small problem.
    If students/staff double clicked a document in mydocs and hadnt already opened word/excel/etc then the software would open but not open the document, leaving them to do it again.
    So I reverted back to a pre-set username in the default user profile but now staff whinge when they cant see whos locked files.

    Pretty sure our contracts should say 'fix all the stupidly small problems that eat up the most time to solve'

  4. #4
    Ryan's Avatar
    Join Date
    Jan 2008
    Location
    Scotland
    Posts
    537
    Thank Post
    12
    Thanked 16 Times in 15 Posts
    Blog Entries
    1
    Rep Power
    29
    If students/staff double clicked a document in mydocs and hadnt already opened word/excel/etc then the software would open but not open the document, leaving them to do it again.
    That is an infuriating bug / 'feature'. Probably confuses countless thousands of people

SHARE:
+ Post New Thread

Similar Threads

  1. Exams and Assessment Officer - Herts
    By SpecialAgent in forum Educational IT Jobs
    Replies: 0
    Last Post: 18th January 2008, 10:10 AM
  2. GP by username
    By rhyds in forum Windows
    Replies: 2
    Last Post: 17th July 2007, 08:01 PM
  3. Spaces in username box
    By jayrt in forum Windows
    Replies: 25
    Last Post: 29th March 2006, 10:54 AM
  4. Halifax, anyone? Principal ICT Network Officer
    By beeswax in forum Educational IT Jobs
    Replies: 0
    Last Post: 6th March 2006, 10:11 PM
  5. IT Officer - (Digischool) - birmigham
    By tosca925 in forum Educational IT Jobs
    Replies: 0
    Last Post: 21st September 2005, 04:36 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •